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. Thanks for the Information. Its very useful
View Tutorial          By: Husain at 2009-03-04 13:30:38

2. Many thanks
View Tutorial          By: tushar at 2010-03-10 01:27:04

3. can we do it this procedure by iteration i know th
View Tutorial          By: sattar at 2010-05-03 03:00:20

4. Plz. help me in getting code to read messages usin
View Tutorial          By: Jaydatta at 2009-04-03 20:58:57

5. You are so great at helping people. ;0
View Tutorial          By: Aaton at 2015-04-24 14:06:57

6. Thanks for the insight. Easily understood.
View Tutorial          By: Bobby Deol at 2014-01-17 00:48:44

7. Please help me i am getting following error messag
View Tutorial          By: Balaji at 2009-09-23 22:54:06

8. It is not useful. bits2 is always changed. be care
View Tutorial          By: ash at 2011-07-25 23:13:30

9. thanks...helped a lot!!!!
View Tutorial          By: Sc21ac at 2013-05-03 03:44:06

10. In the absence of frameworks, this is the best exa
View Tutorial          By: Vitalis at 2014-04-29 17:47:16