Comment on Tutorial - C++ Recursion function explained using Fibonacci series By Emiley J



Comment Added by : nadia

Comment Added at : 2010-10-04 21:48:04

Comment on Tutorial : C++ Recursion function explained using Fibonacci series By Emiley J
how about this?...
#include<iostream.h>

int fibonacci(int n);

int main()
{

int number;

cout <<"Enter an integer :";
cin >> number;

for(int i=0;i<=number;i++)
{
cout <<fibonacci(i) <<" ";
}

cout << endl << endl;
for(i=0;i<=number;i++){
cout <<"Fibonacci "<< i <<" is "<< fibonacci(i) <<endl;

}
return 0;
}

int fibonacci(int n) {
if (n <= 1) {
return n;
} else {
return fibonacci(n-1)+fibonacci(n-2);
}
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. I am doing a project to for sending sms from the s
View Tutorial          By: visalakshi at 2010-03-30 20:55:50

2. I am able to iterate the list.Now i want to print
View Tutorial          By: akanksha at 2012-09-26 05:25:12

3. pls give me example of stack class with postfix me
View Tutorial          By: uchiha at 2011-09-16 04:02:57

4. Thanks for the article. I got some clearance now.
View Tutorial          By: Reddy at 2008-03-15 00:02:17

5. thanks Mr Ramlak
i m using samsung j600 mob

View Tutorial          By: yash at 2008-05-13 15:05:49

6. yes,it is a very nice example for abstract classe
View Tutorial          By: saranya at 2010-07-16 05:56:53

7. can u tell me mobile tracker code in j2me
w

View Tutorial          By: aiyaz at 2010-08-21 16:29:08

8. hi....
can u please show me the code for fi

View Tutorial          By: pooja at 2012-07-08 16:08:08

9. Yesu. Thenk a u vely muchos. HURRRRR
View Tutorial          By: hurr durr at 2013-09-19 19:50:23

10. hi am new to java! i need some simple java program
View Tutorial          By: Anu at 2010-09-08 08:17:49