Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n;
- void fib(int y, int x, int cnt)
- {
- if(cnt == n)
- return;
- cout << x << " ";
- cnt++;
- int t = x;
- x = y;
- y = t + y;
- fib(y, x, cnt);
- return;
- }
- int main() {
- cin >> n;
- fib(1, 0, 0);
- return 0;
- }
Add Comment
Please, Sign In to add comment