Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long int fib(int n)
- {
- long int f1 = 0, f2 = 1;
- int i;
- for (i = 1; i <= n; i += 1)
- {
- f2 = f1+f2;
- f1 = f2-f1;
- }
- return f1;
- }
- 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