Problems
The factorial of a positive integer n is the product of all integers from 1 to n, denoted by n!.
It is defined as:
0! = 1
1! = 1
2! = 2
n! = n × (n-1)!
For example, 4! = 4 × 3 × 2 × 1 = 24.
Write a program that, given n, prints the calculation process for n! and its result.
Note:
If the result exceeds the range of
int, uselong longdata type.Use
%lldfor input/output formatting in C/C++.
Input
A single line containing an integer n (1 ≤ n ≤ 15).
Output
Print the factorial calculation process as shown in the example, ending with the result.
Example
4
4! = 4 * 3!
3! = 3 * 2!
2! = 2 * 1!
1! = 1
24
Tag
Source
JUNGOL