Write a C Program that prompts user to enter any integer number, find the factorial of input number and displays the output on screen. Find the Factorial the Number Using Recursion.
The factorial of a integer N, denoted by N! is the product of all positive integers less than or equal to n. Factorial does not exist for negative numbers and factorial of 0 is 1.
N! = 1 x 2 x 3 x 4....x (N-2) x (N-1) x N
Code:
#include<stdio.h>
#include<conio.h>
int find_factorial(int);
int main() {
int f, num;
printf("Please enter a number: ");
scanf("%d", &num);
f = find_factorial(num);
printf("Factorial: %d", f);
return (0);
}
int find_factorial(int n) {
if (n == 0) {
return (1);
}
return (n * find_factorial(n - 1));
}