Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int X, T;
- unsigned long long int a=0, b=1, c=0, j, i;
- std :: cin >> T;
- for (j = 0; j<T; j++)
- {
- a=0;
- b=1;
- c=0;
- std :: cin >> X;
- for (i=2; i<=X; i++)
- {
- c = b;
- b = b + a;
- a = c;
- }
- if (X==0)
- std :: cout << "Fib(0) = 0" << std :: endl;
- else
- if (X==1)
- std :: cout << "Fib(1) = 1" << std :: endl;
- else
- std :: cout << "Fib(" << X << ") = " << b << std :: endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement