Skip to content

Commit

Permalink
Add: Implementation of factorial in C
Browse files Browse the repository at this point in the history
  • Loading branch information
jebinphilipose committed Oct 1, 2017
1 parent 9aee428 commit 1cba62a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions math/factorial/C/factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<stdio.h>

long long fact(long long x)
{
if(x > 1)
return x*fact(x-1);
else return 1;
}

int main(void)
{
int n, t, s=0, r;
printf("Enter the number: ");
scanf("%d", &n);
printf("\nFactorial of the number is: %lld",fact(n));
return 0;
}
8 changes: 8 additions & 0 deletions math/factorial/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Factorial

Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is 720.

#### Example:

Input : 4 <br/>
Output : 24 <br/>

0 comments on commit 1cba62a

Please sign in to comment.