Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //function definition
- int factorial(int num) {
- if (num == 1) /* base case */
- return (1);
- else
- return (num * factorial(num - 1));
- }
- int main() {
- int x;
- scanf("%d", &x);
- printf("The factorial of %d is %d\n", x, factorial(x));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement