Skip to content

Commit c63f533

Browse files
committed
Create recursion.c
1 parent 14941fc commit c63f533

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Factorial/recursion.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Simple factorial program in C using recursion */
2+
3+
#include <stdio.h>
4+
5+
int fact(int n)
6+
{
7+
if (n == 0)
8+
return 1;
9+
return n * fact(n - 1);
10+
}
11+
12+
int main()
13+
{
14+
int n = 10;
15+
printf("Factorial of %d is %d\n", n, fact(n));
16+
return 0;
17+
}

0 commit comments

Comments
 (0)