While loop

So recently we just started learning while loop.

Now I have a task to do (yes for homework) but I have the main idea how it works.

Basically, I have n. And let's say it's 75.
Now my mission is to find the max square that I can subtract from the number.
Since 9 * 9 is = 81 and 75 > 81 is false I have to check another number.
8 * 8 = 64. 75 > 64 n = 75 - 64
Now my n is 11. And I have to find other.
It wouldn't be hard if it wouldn't ask me to find the higher square.
How do I do that?

I hope you guys got the idea what I'm asking.
pseudo-code:

print n
while n is greater than 0
    set m to square root of n
    cast m to an integer
    subtract m squared from n
    print n
Topic archived. No new replies allowed.