11461 - Square Numbers

All about problems in Volume 114. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11461 - Square Numbers

Post by lighted » Tue Jul 15, 2014 11:48 pm

Third way is close to correct answer.
The problem description:
Given two numbers a and b you will have to find out how many square numbers are there between a and b (inclusive).
Change line

Code: Select all

 if(i==sqrt(i)*sqrt(i))
                coun++;
It is better to work only with integers. sqrt returns double value. :)

Code: Select all

int j = sqrt(i);
if(i==j*j)
      coun++;
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 114 (11400-11499)”