例題2.12

等我刷把宗师發表於2024-10-22

例題2.12程式碼

def factorial(n):
r = 1
while n > 1:
r *= n
n -= 1
return r
def fib(n):
a, b = 1, 1
while a < n:
print(a, end = ' ')
a, b = b, a + b
print('%d! =%d'%(5, factorial(5)))
fib(200)

相關文章