C Programming Code Examples C > Functions Code Examples program to find factorial of a number using recursion program to find factorial of a number using recursion Write a recursive function in C to find factorial of a number. How to find factorial of a number using recursion in C program. Declare recursive function to find factorial of a number First let us give a meaningful name to our function, say fact(). The factorial function accepts an integer input whose factorial is to be calculated. Hence the function declaration should look like fact(int j);. The function returns factorial as an integer value. Since, factorial can grow rapidly hence the suitable return type for this function is unsigned long long. Recursive function declaration to find factorial of a number is - unsigned long long fact(int j); #include <stdio.h> /* Function declaration */ unsigned long long fact(int j); int main() { int j; unsigned long long factorial; /* Input an integer from user */ printf("Enter any number: "); scanf("%d", &j); factorial = fact(j); // Call factorial function printf("Factorial of %d is %llu", j, factorial); return 0; } /* Function to compute and return factorial of any number recursively. */ unsigned long long fact(int j) { // Base condition if(j == 0) return 1; else return j * fact(j - 1); }