Monday, December 10, 2012

Program deret fibonanci


rorogram ini adalah program untuk penghitungn angak fibonanci yang berulang

Program c++
#pragma argsused
#include <iostream.h>           
  class BATAS {
   private:
     long batas, f1, f2, f3;
   public:
     void fibonacci(){
       cout<<"Masukkan bilangan positif : ";
       cin>>batas;
       cout << "Bilangan Fibonacci < " << batas << ":\n 0, 1";
       f1 = 0;
       f2 = 1;
       while (true){
         f3 = f2 + f1;
         if (f3 > batas)break;
         cout<<", "<<f3;
         f1 = f2;
         f2 = f3;
       }
     }
     };
int main(){
  int x;
    BATAS B;
    B.fibonacci();
  cin>>x;
        return 0;
}

0 comments:

Post a Comment