Kamis, 26 Maret 2015

Bilangan Fibonnaci

C++ :

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
long batas;
cout<<"Masukan integer positif : ";
cin>>batas;
cout<<"Bilangan Fibonacci <"<<batas<<":\n0.1";
long f1=0, f2=1;
while(true)
{long f3=f2+f1;
if(f3>batas)break;
cout<<","<<f3;
f1=f2;
f2=f3;
}
return 0;
}


0 komentar:

Posting Komentar

Kamis, 26 Maret 2015

Bilangan Fibonnaci

C++ :

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
long batas;
cout<<"Masukan integer positif : ";
cin>>batas;
cout<<"Bilangan Fibonacci <"<<batas<<":\n0.1";
long f1=0, f2=1;
while(true)
{long f3=f2+f1;
if(f3>batas)break;
cout<<","<<f3;
f1=f2;
f2=f3;
}
return 0;
}


Tidak ada komentar:

Posting Komentar