BILANGAN FOBONACI

#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 fobonaci<"<<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: