Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long int fact(long int n)
- {
- long int f = 1;
- if (n > 0)
- f = n*fact(n-1);
- return f;
- }
- int main(void)
- {
- long int n;
- int qualifier = 1;
- while (qualifier == 1 || qualifier == 0)
- {
- qualifier = scanf("%ld", &n);
- if (qualifier == 1 && n >= 0)
- {
- printf("%ld\n", fact(n));
- }
- if (qualifier == 1 && n < 0)
- {
- printf("wrong type\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement