正整数N(0<=N<=1000)
输入可能包括多组数据,对于每一组输入数据,输出N的阶乘
4 5 15
24 120 1307674368000
大数推荐python
while True: try: n=int(input()) ans=1 while n>0: ans*=n n-=1 print(ans) except: break
#1000的阶乘为10的2568次方 try: while True: num,result = int(input()),1 while num > 1: result *= num num -= 1 print(result) except Exception: pass
python 三行解法:
import math,sys for i in sys.stdin.readlines(): print(math.factorial(int(i.strip())))
while True: try: n = input() res = 1 for i in range(n): res *= (i + 1) print res except EOFError: break
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题