Guest User

Untitled

a guest
Jun 14th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include<stdio.h>
  2. int facto(int n)
  3. {
  4. if(n == 0)
  5. {
  6. return 1;
  7. }
  8. else if(n == 1)
  9. {
  10. return 1;
  11. }
  12. else
  13. {
  14. return n * facto(n-1);
  15. }
  16. }
  17.  
  18. int main()
  19. {
  20. int n,ans;
  21. printf("Enter the number to find factorial: ");
  22. scanf("%d",&n);
  23. ans = facto(n);
  24. printf("%d ! = %d",n,ans);
  25. getch();
  26. return(0);
  27. }
Add Comment
Please, Sign In to add comment