Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- long long fib ( int a, int n, long long f, long long l)
- {
- l+=f;
- f=l-f;
- n++;
- if (n==a-1)
- return f;
- else return fib (a, n, f, l);
- }
- int main()
- {
- int a=0, n=0, l=1, f=0;
- cin >> a;
- if (a==1)
- cout << 0;
- else if (a==2)
- cout << 1;
- else cout << fib (a, n, f, l);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement