Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

피보나치/조재화

From ZeroWiki

데블스캠프 첫째날

세번째로 만드는 프로그램~~(피보나치수열)


#include<iostream>
using namespace std;
int fn(int x); //피보나치수열 
//f(x)=f(x-1)+f(x-2)
int main()
{
	
	int z;
	while(cin>>z)
	{
		int aa;
		aa = fn(z);
		cout<< aa;
		cout<<endl;
	}
	return 0;
}
int fn(int x)
{
	return x<=2 ? 1 : fn(x-1)+fn(x-2) ; 
}

조재화