其實挺簡單的一個問題,原題鏈接:http://www.geeksforgeeks.org/print-squares-first-n-natural-numbers-without-using/
def PrintFirstNSquareNumbers(n):
"""
Print first n numbers without using *, /, -, ** or power
By the simple fact that 1 + 3 + ... + 2n-1 = (1 + 2n-1)/2 * n = n^2
"""
s, x = 0, -1
for i in range(n):
print(s)
x += 2
s += x
# test case
PrintFirstNSquareNumbers(10)