题目描述

求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数字(n不超过20)。

输入

n

输出

样例输入
5
样例输出
153

程序:
#include<stdio.h>
int main()
{
    int i,n;
    long t=1,sn=0.0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        t=t*i;
        sn=sn+t;
    }
    printf("%ld\n",sn);
    return 0;
 }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2021-08-04
  • 2021-08-02
  • 2021-07-07
猜你喜欢
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案