Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- int factorial (int num);
- int main() {
- int n;
- printf("Enter number to calculate factorial: ");
- scanf("%d",&n);
- printf("\n%d",factorial(n));
- return 0;
- }
- int factorial (int num) {
- if ( num <= 1 ) return 1;
- else return num * factorial ( num - 1 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement