41. Factorial of N

Acceptance — 0 accepted 0 submissions

Easy
LoopsMath
No companies listed
In how many ways can N students stand in a line for the school assembly? The answer is N factorial (N!).

N! = 1 × 2 × 3 × … × N, and by definition 0! = 1.

Input Format
A single integer N.

Output Format
Print N!.

Constraints
• 0 ≤ N ≤ 20
• 20! is about 2.4 × 10^18. Use long long in C/C++ or long in Java.

Example 1

Input
5
Output
120

Explanation 5! = 1 × 2 × 3 × 4 × 5 = 120

Example 2

Input
0
Output
1

Explanation 0! is defined as 1.

Example 3

Input
10
Output
3628800

Explanation 10! = 3628800

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
120
No results yet
Run your code to test it against the sample cases.
Problem List