U E D R , A S I H C RSS

피보나치/조재화

No older revisions available

No older revisions available



데블스캠프 첫째날

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

~cpp 

#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) ; 
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:29
Processing time 0.0475 sec