Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- long long int n,count,first,second,f;
- int num,i;
- scanf("%d",&num);
- for(i=1; i<=num; i++)
- {
- scanf("%lld",&n);
- if(n>=0 && n<=60)
- {
- first = 0;
- second = 1;
- count = 0;
- while(count<=n)
- {
- if(count<=1)
- {
- f = count;
- }
- else
- {
- f = first + second;
- first = second;
- second = f;
- }
- count++;
- }
- printf("Fib(%lld) = %lld\n",n,f);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement