大家好
题目是假设给一个n
要print出小于n的square number
例如 n给25
则print出 1 4 9 16
我的code会把0也print
提示说就是写一个while loop
所以我也就是照提示写 如下:
还请各位高手帮忙 谢谢!
import math
n=int(input())
counter=0
while counter*counter<n:
A=counter*counter
if (A<0):
continue
counter = counter+1
counter+1 <math.sqrt(n)
print(A)
我试图想要让print只给我大于0的结果
但没有成功