Find the factorial of each number in an array {4, 3, 2, 5}.
MediumProblem Statement
Find the factorial of each number in an array {4, 3, 2, 5}.
Sample Input
4 3 2 5
Sample Output
24 6 2 120
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <stdio.h>
int factorial(int num) {
// Your code here
}
int main() {
int arr[] = {4, 3, 2, 5};
for (int i = 0; i < 4; i++) {
printf("%d ", factorial(arr[i]));
}
printf("\n");
return 0;
}
Input
4 3 2 5
Expected Output
24 6 2 120