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. it is 3 days since I searched resolution. It was h
View Tutorial          By: Daniel Costa at 2009-02-25 06:11:27

2. thanks for providing information in a simple langu
View Tutorial          By: shailaja at 2010-09-01 03:50:41

3. when i trying to build the above program it is giv
View Tutorial          By: bhagyalaxmi at 2008-10-10 23:45:45

4. no output is shown
View Tutorial          By: shubham bansal at 2015-02-21 15:36:31

5. i need help in java
View Tutorial          By: arjun tanwar at 2010-02-17 20:58:55

6. how do i use the jsapi classes and the freets pack
View Tutorial          By: Chileshe at 2012-08-22 14:23:38

7. I don't like Java for not supporting pointers.
View Tutorial          By: Yannbane at 2012-10-14 12:16:27

8. how to trim in jsp page and to send the trimed con
View Tutorial          By: monishaa at 2015-07-16 10:06:11

9. This tutorial is very good. Actually I have been s
View Tutorial          By: farhaan at 2008-03-20 15:22:13

10. Hello every one. I am working on my project in j2m
View Tutorial          By: Pradeep Reddy at 2011-01-04 05:15:51