All problems

Problem 7

Factorial of a Number

Easy · 10 pts · Math, Recursion

Problem

You are given a non-negative integer N. Print N factorial, written N!, which is the product of all positive integers from 1 to N: N! = 1 × 2 × 3 × ... × N. By definition 0! = 1. Factorials grow very quickly: 20! is about 2.4 × 10^18, which needs a 64-bit integer type (long long in C++, long in Java). A 32-bit int overflows already at 13!.

Input

A single integer N.

Output

Print N factorial.

Constraints

0 <= N <= 20

Example input

5

Example output

120

Explanation

For N = 5, the product is 5 × 4 × 3 × 2 × 1 = 120, so 5! = 120.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Valid Parentheses Next: Prime Number Check