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