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



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 digital shell clock: very cool, and
View Tutorial          By: Lol loller at 2012-04-11 15:40:45

2. Hi Mirna,
U r talking abt speech to text co

View Tutorial          By: akshat at 2012-04-02 14:38:31

3. hi!
please tell how i got the java comm api

View Tutorial          By: suresh at 2010-08-22 03:29:06

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

5. thanks for to solve my doubts
View Tutorial          By: puttaswamy B S at 2010-09-28 00:45:47

6. Hi...i know java but little....
give simple

View Tutorial          By: Murshidha at 2012-02-06 09:52:52

7. I have altered the code as described (xml addition
View Tutorial          By: Spijker at 2015-10-14 12:27:47

8. It's Very Nice. Particularly:
DO use memmov

View Tutorial          By: Rasmi Ranjan Nayak at 2010-01-12 04:40:18

9. Its really good and helpfull..........
chee

View Tutorial          By: sumit at 2009-04-28 05:17:17

10. Dude how did you used out.print() method it is giv
View Tutorial          By: Hardik at 2013-02-18 15:37:09