Skip to content

Commit

Permalink
Factorial Using Recrusion
Browse files Browse the repository at this point in the history
C Program to calculate factorial using recursion.
  • Loading branch information
Ramjonchhen committed Oct 19, 2021
1 parent 85cb56d commit 9cdb213
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions C/Factorial Using Recursion.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>

int factorial(int n) {
if(n==0 || n==1) {
return 1;
} else {
return factorial(n-1)*n;
}
}

int main()
{
int num;
printf("Enter Number to find the factorial: ");
scanf("%d",&num);
printf("\n The factorial of %d is %d",num,factorial(num));;
return 0;
}

0 comments on commit 9cdb213

Please sign in to comment.