Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/faktoriallar-yigindisi

Sum of factorials

Easy 1000 ms 64 MB 28%
Share

A positive integer $N$ is given. Compute the sum of the factorials of the first $N$ positive integers:

$$S = 1! + 2! + 3! + \dots + N!, \qquad k! = 1 * 2 * \dots * k$$

The sum of a sequence of factorials

Input

One positive integer $N$.

Output

One integer — $S$.

Note

$1 \le N \le 20$

Examples

Input #1
1
Output #1
1
Input #2
2
Output #2
3

Sign in to submit a solution

Signing up is free and takes a minute.