Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- long readNumber();
- long factorial(long b);
- int main()
- {
- long x;
- x = readNumber();
- factorial(x);
- printf("\nErg: %ld", factorial(x));
- return 0;
- }
- long readNumber()
- {
- long i;
- printf("\nGeben Sie eine ganze Zahl ein: ");
- scanf("%ld", &i);
- return i;
- }
- long factorial(long b)
- {
- long i, fact=1;
- if(b <= 0)
- {
- return 0;
- }
- for(i=1; i<=b ; i++)
- {
- fact = fact * i;
- }
- return fact;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement