PCLP2/lab07/01.cpp

23 lines
250 B
C++
Raw Normal View History

2020-05-01 14:58:05 +00:00
#include <iostream>
using namespace std;
int fib(int n){
if(n <= 1){
return n;
}
return fib(n-1) + fib(n-2);
}
int main(){
int n;
cout<<"N = ";
cin>>n;
for(int i=0; i<n; i++){
cout<<fib(i)<<", ";
}
cout<<"\b\b "<<endl;
return 0;
}