Advertisement
Guest User

Untitled

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