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