make the function number Fibonaci iterative manner.

making it highly iterative function is easy, but how to use the function takes a lot of memory, the following example program:


class Operator{
friend ostream& operator<<(ostream&,Operator&);
friend istream& operator>>(istream&,Operator&);
long fibonacci(int);
int n;
int fibonacci(int n)
{ if((n==1)||(n==2))return(1);
else return (fibonacci(n-1)+fibonacci(n-2));
ostream& operator<<(ostream& out,Operator& a){
for(int i=1;i<=a.n;i++)
return out;
istream& operator>>(istream& in,Operator& a){
cout<<“sampai suku ke:”;
return in;
int main(){
Operator run;
cin >> run;
cout << run;


try it 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: