Sabtu, 09 April 2016

mencari suku n fibonacci #kasus 5.6

Kasus 5.6

 //SELAMAT MENCOBA YA:
 
 #include <iostream>
#include <string>
using namespace std;
void fibonacci(int n,int f1,int f2,int x){
 int f3;
 if(x>(n-2)){
 }
else{
 f3=f1+f2;
 cout<<f3<<", ";
 f1=f2;
 f2=f3;
 x=x+1;
 fibonacci(n,f1,f2,x);
}
}
int main() {
 int f1;
 int n;
 int f2;
 int x;
 cout<<"masukan suku ke-n : ";
 cin>>n;
 cout<<"fibonacci suku ke-"<<n<<endl;
 x=1;
 f1=0;
 f2=1;
 cout<<f1<<", "<<f2<<", ";
 fibonacci(n,f1,f2,x);
 return 0;
}
//HASIL PROGRAM DI ATAS:

 RAPTOR

Unknown

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 komentar:

Posting Komentar