#include<stdio.h> #include<math.h> int step(int a) { int power=0; if (a == 1 || a == 0) power = a; if (a > 1) power= a*step(a-1); return power; } int main() { int m,n; long sum = 0; printf("请输入n:\n"); scanf_s("%d",&n); for (m=1;m<=n; m++ ) { sum = sum + step(m); } printf("1!+2!+3!+...+n!=%d", sum); }