입력 n(~30)이 주어질 때, n번째 피보나치 수를 구해서 출력하시오.
6 / 8
#include <iostream>
// 1 1 2 3 5 8 ...
int Recursive(int _Count, int _Left = 0, int _Right = 1, int _Num = 0)
{
if (_Count == 1)
{
return _Num;
}
_Num = _Left + _Right;
_Left = _Right;
_Right = _Num;
return Recursive(_Count - 1, _Left, _Right, _Num);
}
int main()
{
int Count = 0;
std::cin >> Count;
std::cout << Recursive(Count);
}