Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:25:46+00:00 2026-05-14T03:25:46+00:00

In my application, a cool number is a number that is both a square

  • 0

In my application, a “cool” number is a number that is both a square and a cube, like for example: 64 = 8^2 and 64 = 4^3. My application is supposed to find the number of “cool numbers” between a range given by the user. I wrote my code and the application runs fine, but it is giving me the wrong answer. Can you help me here please? for example:

INPUT

1
100

OUTPUT

1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double a = Convert.ToDouble(Console.ReadLine()); // first number in the range
            double b = Convert.ToDouble(Console.ReadLine()); // second number in the range
            long x = 0;
            for (double i = a; i <= b; i++)
            {   

                   double cube = 1.0 / 3.0;
                   double cuad = 1.0 / 2.0;
                   double crt = Math.Pow(i, cube); // cube root 
                   double sqrt = Math.Pow(i, cuad); // square root


                if ((crt * 10) % 10 == 0 || (sqrt * 10) % 10 == 0) // condition to determine if it is a cool number.
                    x++;

            }
            Console.WriteLine(x);
            Console.ReadLine();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:25:47+00:00Added an answer on May 14, 2026 at 3:25 am

    The || operator is meant to evaluate to true if one of the parts is true, so your condition will evaluate to true whether is exact cube OR exact square
    if ((crt * 10) % 10 == 0 && (sqrt * 10) % 10 == 0)

    This is another option, a bit slow but you can test it:

    if (((crt == Math.Floor(crt)) && (sqrt == Math.Floor(sqrt))) x++;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've always worked with web application and that's what I like to do. For
The application my team is currently developing has a DLL that is used to
The application I'm writing is almost complete and I'd like people who speak different
Many of us have web and application servers that use plain TCP. Some of
I've always found that defining URLs for other pages in a Web Application seems
I currently try to create classes for a paint-like WPF application. I have to
I'm creating a cool Home application in Android. As this is a Home app
I am creating an application, built with PHP, MySQL and Doctrine v1.2, that deals
I am writing a mac application that uses the scripting bridge to control iTunes.
I've been given a for fun challenge to write a hello world application. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.