You are given an integer . Print the factorial of this number.
Input
Input consists of a single integer , where .
Output
Print the factorial of .
Example
For an input of , you would print .
Note: Factorials of can't be stored even in a long long variable. Big integers must be used for such calculations. Languages like Java, Python, Ruby etc. can handle big integers, but we need to write additional code in C/C++ to handle huge values.
We recommend solving this challenge using BigIntegers.
#!/bin/python3 # Extra Long Factorials # author : Jung myeonggwang # version : 1.0 import sys def extraLongFactorials(n): # this extraLongFactorias is return factorial num num = 1; # 0 부터 넣으면 곱했을때 0만 나오기 때문 for i in range(1,n+1): # 따라서 range 범위를 1부터 시작 num *= i print(num); if __name__ == "__main__": n = int(input().strip()) extraLongFactorials(n)
'Algorithm Project' 카테고리의 다른 글
| 003.Hawk eyes (0) | 2017.12.01 |
|---|---|
| 002. 한수 (0) | 2017.11.27 |
| 001. 피보나치 함수 (0) | 2017.11.15 |
| 000. 알고리즘 공부 (0) | 2017.11.15 |
댓글