- 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(); }
1 komentar:
nice info jun :)
follow blog aku ya. :)
Posting Komentar