Whole number square roots only? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Whole number square roots only?

I need to write a program that will list the fibonacci sequence up until a million (This part is done) and then out of the numbers, I need to take the square roots, and only print the ones that return whole numbers, if I take the square roots of each number (being int's, It will return all the answers rounded to the nearest whole number, which is not what I need. Since I don't even know where to begin on this, I have no code implementing the square root portion. Not asking for it to be done for me , just where do I start maybe? Thanks

Language - C

#include
#include
int main(void)
{

int x, y, z,c,s;
double d;

x=1; /*Initiating the first values of the fibonacci sequence*/
y=1;
z=0;
c=1; /*Initiating the first value for the count*/

printf("%d
", x); /*The first two values of the sequence are printed here*/
printf("%d
", y);
while (z<1000000)
{
z=x+y;
x=y;
y=z;
c++;

if (z<1000000)
printf("%d
", z);

}
printf("The amount of numbers in the follwing sequence is %d
", c);

return (0);

}
Sign In or Register to comment.