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

~/algor $ cat problems/funksiya-faktoriallar-yigindisi

Sum of two factorials

Easy 1000 ms 128 MB 27%
Share

Write a function FactorialSum(a, b) that returns the sum $a! + b!$ for non-negative integers $a$ and $b$.

$$n! = 1 * 2 * \ldots * n, \qquad 0! = 1$$

Example 1: FactorialSum(3, 4) → 30 — $6 + 24 = 30$.

Example 2: FactorialSum(0, 5) → 121

Write only the function body.

Two numbers go into the function FactorialSum, which returns the sum of their factorials

Input

One line with two non-negative integers $a$ and $b$ — the arguments of the function.

Output

The value returned by the function: an integer.

Note

$0 \le a, b \le 17$

Examples

Input #1
3 4
Output #1
30
Input #2
0 5
Output #2
121

Sign in to submit a solution

Signing up is free and takes a minute.