C Program To Find Factorial Using Recursion

C program to find factorial of a number using recursion.Write a C program to find factorial of a number using recursive function. C Program :
/* Aim: Write a recursive program to factorial of given number */ 

#include<stdio.h>

long int Factorial(int num);// Factorial Function Prototype

void main()
{
	int num;
	printf("\n Enter any number:- ");
	scanf("%d",&num);

	printf("\n Factorial of %d is %d \n \n",num,Factorial(num));
}

// Factorial Function

long int Factorial(int num)
{
	if(num==0 || num==1)
	return 1;
	else 
	return (num*Factorial(num-1));
} // End of the code 


/* Output of above code:-

[root@localhost ~]# cc re_factorial.c
[root@localhost ~]# ./a.out

 Enter any number:- 5

 Factorial of 5 is 120 
 
*/ 

Comments