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



Ask a Question

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. i have run the program..bt there r so many excepti
View Tutorial          By: ayan at 2010-05-26 10:37:51

2. good start up fr java beginers
View Tutorial          By: sandeep Ch at 2012-01-06 07:16:34

3. hi, i would like to know about sms sendimg via web
View Tutorial          By: abhi at 2008-07-09 07:28:54

4. I like your explanition its very uesfull
View Tutorial          By: Salah Mohamed at 2011-12-10 15:47:27

5. how to write an byte array containing 10 different
View Tutorial          By: sanjana at 2015-01-17 06:32:41

6. Thank uvery much :) u r so helpful
View Tutorial          By: Ahmed at 2011-12-04 10:01:11

7. Could any one please send the working source code
View Tutorial          By: Raviteja at 2014-06-24 05:27:43

8. Thx, this helped a lot.

How can I I

View Tutorial          By: Marko at 2008-10-09 01:32:37

9. Please tell me the full program for insert values
View Tutorial          By: Mohamed Ussain at 2009-08-28 23:14:47

10. Excellent explanation...Thanku.
View Tutorial          By: Rajpal Singh at 2012-12-29 05:36:20