例題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)
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)