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. Can any help me to get Second line,Second word in
View Tutorial          By: Ramesh at 2012-07-21 11:12:05

2. Thanks this page is very useful for me and now I k
View Tutorial          By: Yee Wai Wyne at 2009-10-18 23:03:41

3. hey. How would i get the ClientLists displayed in
View Tutorial          By: andrew at 2009-07-24 14:10:24

4. how to append data to existing excel sheets withou
View Tutorial          By: nim at 2011-03-23 00:28:10

5. I am using my NOKIA 6630 via usb connection, runni
View Tutorial          By: muhin at 2010-04-19 21:37:02

6. Hai.. i tried with d above code but am getting an
View Tutorial          By: muthupandi at 2010-08-17 09:49:23

7. Hi it is working fine .but when my server we imple
View Tutorial          By: mohan at 2014-11-28 10:57:22

8. why the code had error in status???
View Tutorial          By: matuz at 2011-11-13 11:35:34

9. How we print this structure in C++, with nested lo
View Tutorial          By: Hussnain at 2012-01-27 09:19:41

10. dear i have different files of ms access 2010 like
View Tutorial          By: neeo at 2012-01-16 07:02:20