为什么要n = n - 1?
def power(x, n):
s = 1
while n > 0:
n = n - 1
s = s * x
return s
比如5的3次方
减一之后不就变成了5的2次方了吗
def power(x, n):
s = 1
while n > 0:
n = n - 1
s = s * x
return s
比如5的3次方
减一之后不就变成了5的2次方了吗
2018-01-17
举报