0
0

More than 1 year has passed since last update.

paizaラーニング「階乗の計算 Python3編」

Posted at

私の解答

n = int(input())
ans = 1
for i in range(2,n+1): 
    ans = ans * i
print(ans)

解答例1

N = int(input())

factorial = 1
for i in range(2, N + 1):
    factorial *= i

print(factorial)

解答例2

from math import factorial

N = int(input())

print(factorial(N))
  • Python の場合、 math モジュールの factorial 関数を使用すると、階乗の計算を行うことができます。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0