No older revisions available
No older revisions available
~cpp #include <iostream> using namespace std; int fibonach(int num); void main() { int input; cout<<"숫자를 입력해봐요\n"; cin>>input; cout<<input<<"번째 피보나치 수열은 "<<fibonach(input)<<"\n"; } int fibonach(int num) { if(num<=1) return num; return fibonach(num-1)+fibonach(num-2); }
~cpp //파이선으로 작성 def fibonach(a): if a<=1: return a return fibonach(a-1) + fibonach(a-2) if __name__ == '__main__': a=int(raw_input("input number")) print fibonach(a)