Advertisement
Guest User

taylor min a

a guest
Apr 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. long readNumber();
  5. long factorial(long b);
  6.  
  7. int main()
  8. {
  9. long x;
  10.  
  11. x = readNumber();
  12. factorial(x);
  13. printf("\nErg: %ld", factorial(x));
  14.  
  15. return 0;
  16. }
  17.  
  18. long readNumber()
  19. {
  20. long i;
  21. printf("\nGeben Sie eine ganze Zahl ein: ");
  22. scanf("%ld", &i);
  23. return i;
  24. }
  25.  
  26. long factorial(long b)
  27. {
  28. long i, fact=1;
  29.  
  30. if(b <= 0)
  31. {
  32. return 0;
  33. }
  34.  
  35. for(i=1; i<=b ; i++)
  36. {
  37. fact = fact * i;
  38. }
  39. return fact;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement