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. when i trying to build the above program it is giv
View Tutorial          By: bhagyalaxmi at 2008-10-10 23:45:45

2. how to execute all the 5 files plz tell me step by
View Tutorial          By: asraf at 2007-11-14 22:29:20

3. Seriously very nice explanation.... Thank You
View Tutorial          By: Pulkit agrawal at 2012-03-20 10:28:10

4. plz xplian robust in a simple way and what is dyna
View Tutorial          By: tintu at 2011-12-01 08:21:25

5. Very Nice Explanation.
View Tutorial          By: Anuj Bansal at 2012-08-25 12:23:59

6. Good example for vector
View Tutorial          By: mangai at 2011-07-07 09:46:10

7. the article is very useful...!
View Tutorial          By: pravin salame at 2011-05-20 11:58:28

8. what about the remaining explanation......do anyth
View Tutorial          By: raki at 2011-11-07 10:47:25

9. great job
i seriously feel that this site i

View Tutorial          By: saurabh at 2012-01-17 05:28:32

10. class thrs
{
public void run()

View Tutorial          By: vivek tiger at 2012-04-19 10:19:56