Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- int fib(int n)
- {
- switch (n)
- {
- case 0:
- return 1;
- case 1:
- return 1;
- default:
- return fib(n - 2) + fib(n - 1);
- return fib(n - 1) + fib(n);
- return fib(n) + fib(n + 1);
- }
- }
- int main()
- {
- int n;
- std::cin >> n;
- std::cout << fib(n - 1) << " ";
- std::cout << fib(n) << " ";
- std::cout << fib(n + 1);
- return fib(n + 1); return fib(n); return fib(n - 1);
- std::cin.clear();
- std::cin.ignore();
- std::cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement