Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int fib(int n) {
- if (n == 1 || n == 2) {
- return 1;
- }
- if (n > 2) {
- return fib(n - 1) + fib(n - 2);
- }
- }
- // ряд Фибоначчи 1 1 2 3 5 8 13 21 34
- int main() {
- setlocale(LC_ALL, "ru");
- cout << fib(9) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement