Sum of Factorials up to N
Given a non-negative integer n, return 1! + 2! + ... + n!. When n is 0, the series is empty and the answer is 0.
Given a non-negative integer `n`, return `1! + 2! + ... + n!`. When `n` is `0`, the series is empty and the answer is `0`.
- `0 <= n <= 12` - The answer fits within a 32-bit signed integer.
Example 1: input n = 4; output 33. 1! + 2! + 3! + 4! = 1 + 2 + 6 + 24 = 33.
Example 2: input n = 0; output 0. The series has no terms.
Example 3: input n = 3; output 9. 1 + 2 + 6 = 9.
Category: Math. Topic: math. Difficulty: Easy. Patterns: math.