标签:otto turn class transform ace title src 测试 while
问题 1014: [编程入门]阶乘求和
时间限制: 1Sec 内存限制: 128MB 提交: 27629 解决: 5450
求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数字(n不超过20)。
n
Sn的值
5
153
# 10014:阶乘求和 # Sn = 1! + 2! + 3! +...+n! def factorial_cal(n): ‘‘‘ cal n! ‘‘‘ sum_t = 1 while n>1: sum_t = sum_t * n n = n-1 return sum_t if __name__ == ‘__main__‘: n = int(input()) sum = 0 if n>=0 & n<=20: while n>0: sum_temp = factorial_cal(n) sum = sum + sum_temp n=n-1 print (sum)
本地测试正确:
出错:
运行报错
问题 1014: [编程入门]阶乘求和):(本地测试正确;但提交不对!!??)求教
标签:otto turn class transform ace title src 测试 while
原文地址:https://www.cnblogs.com/cainiaoxuexi2017-ZYA/p/11624406.html