Skip to content

Python 306 迴圈階乘計算

Python TQC

題目說明:

請使用迴圈敘述撰寫一程式,讓使用者輸入一個正整數n,利用迴圈計算並輸出n!的值。

範例輸入
15

範例輸出

1307674368000

Solution

1
2
3
4
5
a = eval(input())
SUM = 1
for i in range(1, a+1):
    SUM *= i
print(SUM)

Warning

SUM記得從1開始,否則結果值會是0


Last update : 13 novembre 2024
Created : 13 novembre 2024

Comments

Comments