Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
242
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.  
  3. int factorial(int n) {
  4. if (n == 0)
  5. return 1;
  6. else
  7. return (n * factorial(n-1));
  8. }
  9.  
  10. int main(){
  11. int n,result;
  12. printf("Enter the value of n: ");
  13. scanf("%d",&n);
  14. result = factorial(n);
  15. printf("Factorial is : %d",result);
  16.  
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement