#C824. Factorial Array
Factorial Array
Factorial Array
You are given an array of non-negative integers. Your task is to compute the factorial for each integer in the array and output a new array containing these factorials.
The factorial of a non-negative integer \(n\) (denoted as \(n!\)) is defined as:
\( n! = \prod_{i=1}^{n} i \) with the special case \(0! = 1\).
For example, given the array [1, 2, 3, 4], the output should be [1, 2, 6, 24].
inputFormat
The input is a single line containing space-separated integers. The first integer (n) represents the number of elements in the array, followed by (n) non-negative integers.
outputFormat
Output a single line of space-separated integers, where each integer is the factorial of the corresponding input number.## sample
4 1 2 3 4
1 2 6 24