forked from ZoranPandovski/al-go-rithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Implementation of factorial in C
- Loading branch information
1 parent
9aee428
commit 1cba62a
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/> |