
Python 入門指南 5.0
exercise1005.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # 定義計算階乘的函數 def factorial(number): # 暫存結果的變數 result = 1 # 計算到 count 的階乘 for i in range(1, number+1): result *= i # 回傳計算結果 return result # 印出計算結果 print(factorial(5)) # 檔名: exercise1005.py # 說明:《Python入門指南》的練習 # 網站: http://kaiching.org # 作者: 張凱慶 # 時間: 2023 年 8 月 |
