U E D R , A S I H C RSS

피보나치/곽세환

~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);
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0100 sec