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. Hi ,Razvan

I changed code as in you

View Tutorial          By: sanil at 2011-01-01 11:05:53

2. Very good article on string , please also mentions
View Tutorial          By: Subham at 2014-04-29 18:01:04

3. where i can find Messageressourse.properties......
View Tutorial          By: sanjiv at 2013-09-07 06:59:19

4. can any beginners can try creating web pages

View Tutorial          By: jo at 2015-07-28 19:35:11

5. Good Example esp. way it was presented.
View Tutorial          By: Arunlal at 2013-06-20 11:56:43

6. i have been searching for this result for more tha
View Tutorial          By: nithin at 2010-08-08 12:55:18

7. I got intersting idea about gauge,thanks...
View Tutorial          By: Marimuthu at 2009-07-20 00:56:27

8. pretty simply explained
View Tutorial          By: nivedita at 2011-06-09 07:32:58

9. thank you for code
View Tutorial          By: turki at 2013-12-11 13:23:44

10. Thanks for providing detailed information .
View Tutorial          By: CM Mankar at 2008-03-18 04:37:03