#C13346. Factorial Computation
Factorial Computation
Factorial Computation
Given a non-negative integer n, compute its factorial defined as \( n! = n \times (n-1)! \) with the base case \( 0! = 1 \). If the input is negative, output the error message "Factorial is not defined for negative numbers".
You need to write a complete program that reads the input from stdin
and writes the output to stdout
. The program should be able to handle the following scenarios:
- When n is 0 or 1, the output is 1.
- When n is positive, compute and output the factorial of n.
- When n is negative, print the exact error message.
inputFormat
The input consists of a single integer n provided via standard input.
outputFormat
If n is non-negative, output the factorial of n as an integer. If n is negative, output the error message "Factorial is not defined for negative numbers".
## sample0
1