Advertisement
aiNayan

7(iv)

Dec 7th, 2020
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <stdio.h>
  2. int factorial(int n)
  3. {
  4. if (n == 0)
  5. return 1;
  6. else if (n == 1)
  7. return 1;
  8. return factorial(n - 1) * n;
  9. }
  10. int main()
  11. {
  12. int n;
  13. printf("Enter the number: ");
  14. scanf("%d", &n);
  15. printf("%d! = %d\n", n, factorial(n));
  16. return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement