游客 Signup | Login
中文 | En

1306 - C语言程序设计教程(第三版)课后习题6.4

通过次数

0

提交次数

0

Time Limit : 1 秒 Memory Limit : 128 MB

求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数字。

Input

n

Output

Examples

Input Format

5

Output Format

153

Solution C++

#include<iostream>
using namespace std;
int main()
{
	int n,t=1;
	cin>>n;
	long long sn=0;
	for (int i=1; i<=n; i++)
	{
		t*=i;
		sn+=t;
	}
	cout<<sn<<endl;
	return 0;
}