Skip to content

Commit

Permalink
Factorial using Recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
HazraSohini committed Oct 12, 2023
1 parent e5dad3f commit 3c0abb3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
int rec(int n)
{
if(n==0)
return 1;
else
return n*rec(n-1);

}
int main(void)
{
int n;
printf("Enter number:\n");

scanf("%d",&n);

int a=rec(n);
printf("%d\n",a);
return 0;

}

0 comments on commit 3c0abb3

Please sign in to comment.