Hi,
I am trying to write a loop that lists all the square results until the number given in.
So for example if i would give in 100 it would list the squares in a list wich would be 1, 4, 9, 16 etc...
The problem is i if i increase the count i am getting wrong results wich go from 1, 4, 25, .....I suppose i need to work with a variable or?
A bit of a stupid question, but i cannot seem to get it to work. (ive tried both a while and a for version).
The value of the count keeps being "reminded" so it will keep counting up incorrect values. So how do i obtain 1*1, 2*2, 3*3, 4*4 , 5*5, ...?
So the proper values will apear as 1, 4, 9 , 16 on the screen.
Regards.
Console.Write("Give in a number...");
ulong Number = ulong.Parse(Console.ReadLine());
ulong Count = 1;
while (Count <= Number)
{
Count = Count * Count;
Console.WriteLine("{0}", Count);
Count = Count + 1;
}