Program Deret Fibonacci secara Rekursif dengan Bahasa C++

#include <iostream>
using namespace std;

int Fibonacci(int n){
int a, b, c, i;
if(n==0){
return 0;
}
else if (n==1){
return 1;
}
else{
a=0;
b=1;
i=2;
while (i<=n){
c=a+b;
a=b;
b=c;
i=i+1;
}
return c;
}
}

int main() {
int i, n;
cout<<"masukkkan deret fibonacci : ";cin>>n;
cout<<endl;
cout<<"deret fibonacci : ";
for(i=0; i<n; i++){
cout<<Fibonacci(i)<<"  ";
}
return 0;
}

Comments

Popular posts from this blog

Cara Membuat Halaman Login Hotspot Berbeda pada 1 Mikrotik

UltraISO Premium Edition v9.5.3

Arti OSAKMJ