Untitled

 avatar
unknown
c_cpp
a year ago
484 B
5
Indexable
#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;
}
Editor is loading...
Leave a Comment