Pages

Rabu, 14 Desember 2011

MENGHITUNG BANYAKNYA BILANGAN FIBONACI [TUGAS SD PRATIKUM]

  • C++
  • #include 
    #include 
    
    int fibonacci(int n){
    if(n==1)
    return(0);
    else if(n==2)
    return(1);
    else
    return (fibonacci(n-1)+fibonacci(n-2));
    }
    
    int jum(int b,int a)
    {
    int x=0;
    for(int n=1; fibonacci(n)<=a; n++){
    if ( fibonacci(n) >= b && fibonacci(n) <= a )
    x=x+1;
    }
    return(x);
    }
    
    
    void main()
    {
    int b,a;
    cout <<" BILANGAN fibonacci " << endl;
    cout <<" ------------------------ "<>b;
    cout <<" batas atas  : ";cin>>a;
    
    cout <<"\n jumlah = " << jum(b,a);
    getch();
    }
    
    
    
  • HASIL
Print Friendly and PDF

Artikel Terkait:

1 komentar:

J.K mengatakan...

nice info jun :)
follow blog aku ya. :)

Posting Komentar

Related Posts Plugin for WordPress, Blogger...