Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
32

6.1. While: List of squares

pole55
pole55

"For a given integer N, print all the squares of positive integers where the square is less than or equal to N, in ascending order."

Example input
50

Example output
1 4 9 16 25 36 49

4 years ago
You are viewing a single comment. View All
1
girianshiido
girianshiido

@pole55
Did you try your code with 10000000000?
Your code doesn't tell to stop at 10^5. It'll try to compute each square from 1 to x², even if i² is already greater than x. Of course, none of these numbers will be in the list, because they don't verify the condition.

4 years ago