大家好
題目是假設給一個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的結果
但沒有成功