#42Easy
Sum of factorials
Time: 1 s · Memory: 256 MB
- Loops
Statement
You are given a natural number . Find , where .
Input format
A single integer ().
Output format
A single integer — the sum.
Examples
Input
4
Output
33
Input
1
Output
1
Note
You do not need to compute each factorial from scratch: . Update the current factorial inside one loop and add it to the sum.
, and already does not fit into 32 bits. Use long long in C++ and int64 in Go. In the first example: .
