2260 - b1009
时间限制 : 1 秒
内存限制 : 128 MB
编程实现求1到5的阶乘的和。
题目输入
题目输出
输入/输出样例
输入格式
输出格式
C语言解答
#include<stdio.h> int main() { int a,b,c,d; b=0; for(c=1;c<7;c++) { a=1; d=c; while(--d) { a=a*d; } b+=a; } printf("%d\n",b-1); return 0; }
C++解答
#include<iostream> #include<cstdio> #include<iostream> #include<cmath> using namespace std; int main(){ int sum=0,temp=1; for(int i=1;i<=5;i++){ temp *= i; sum += temp; //cout<<sum<<endl; } cout<<sum<<endl; return 0; }
Python解答
# coding=utf-8 def jc(n): if n == 1 : return 1 else: return n*jc(n-1) s = 0 for i in range(1,6): s += jc(i) print(s)