Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
484 B
1
Indexable
Never
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int fibanachi(int n)
{
    if (n == 0)
    {
        return 0;
    }
    if (n == 1)
    {
        return 1;
    }
    else
    {
        return fibanachi(n - 1) + fibanachi(n - 2);
    }
}
int main()
{
    setlocale(LC_ALL, "russian");
    int n;
    cout << "Введи номер числа Фибоначи : ";
    cin >> n;
    cout << fibanachi(n) << endl;
    return 0;
}
Leave a Comment