~cpp 
#include <iostream>
using namespace std;

int f(int, int, int);

int main()
{
	int n;
	cout << "몇번째 수? : ";
	cin >> n;
	
	if (n == 1)
		cout << 1;
	else
		cout << f(1, 1, n-1);
	cout << endl;

	return 0;
}

int f(int a, int b, int n)
{
	if (n == 1)
		return a + b;
	else
		return f(b, a+b, n-1);
}


Retrieved from http://wiki.zeropage.org/wiki.php/피보나치/곽세환
last modified 2021-02-07 05:31:27