answersLogoWhite

0


Best Answer

STEP1. Set value of count=1, output=1, T1=0, T2=1

STEP2. Read value of n

STEP3. Print output

STEP4. Calculate

output=T1+T2

STEP5. T1=T2 & T2=output

STEP6. Calculate count= count+1

STEP7. If (count<=n>

go to STEP3

else

go to STEP8

STEP8. End

You could also just plug in n into this formula:

F(n) = [φ^n - (1-φ)^n] / sqrt(5)

φ is about 1.618033989 and is the Golden Ratio

[It's also the limit as n approaches infinity of the nth term in the Fibonacci sequence divided by the (n-1)th term]

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

#include
#include

using std::cin;
using std::cout;
using std::endl;
using std::tolower;

long factorial(const int& N);

int main()
{
int N = 0; //factorial of N
char command = 'n';
do
{
cout << "Enter a number to calculate factorial: ";
cin >> N;

cout << endl << "Factorial of " << N << " is: " << factorial(N) << endl;

cout << "Do you want to continue (y/n)?";
cin >> command;
cout << endl;
} while ('y' == tolower(command));

system("PAUSE");
return 0;
}

long factorial(const int& N)
{
if (N == 0)
{
return 1;
}
else
{
return (N * factorial(N - 1));
}
}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

ops sorry .......................................

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Recursive function to find nth number of the Fibonacci series?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program to print the Fibonacci series in php upto input value using recursive function?

The Fibonacci sequence uses recursion to derive answers. It is defined as: F0 = 0 F1 = 1 Fn = F(n - 1) + F(n -2) To have this sequence printed by a php script use the following: function fibonacci($n) { if($n 1) return 1; //F1 else return fibonacci($n - 1) + fibonacci($n - 2); //Fn } This recursive function will print out the Fibonacci number for the integer n. To make it print out all the numbers in a particular set add this to your script. for($i = 0; $i &lt; 15; $i++) { echo fibonacci($i) . "&lt;br /&gt;"; } So your final result would look like. &lt;?php function fibonacci($n) { if($n 1) return 1; else return fibonacci($n - 1) + fibonacci($n - 2); } for($i = 0; $i &lt; 15; $i++) { echo fibonacci($i) . "&lt;br /&gt;"; } ?&gt;


Multithreaded program generates Fibonacci series using java-answer?

The formula for the Fibonacci series isFn = Fn-1 + Fn-2 for n &acirc;&permil;&yen; 2 with F0 = 0 and F1 = 1.In layman's terms, in the Fibonacci series each successive number is the sum of the previous two numbers, starting with 1. So we have 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etcTo do this in Java or any computer program you will need to create a recursive program, one that picks up previous values. This is quite easy, even for a beginner, once one grasps the Fibonacci fundamentals. Here is an example in Java:public class Fibonacci {public static long fib(int n) {if (n


Write a program to generate the Fibonacci series using non-recursive method?

In c: int fibr(int n) { // Find nth Fibonacci number using recursion. if (n&lt;=2) return 1; // the first two Fibonacci numbers are 1 and 1 return (fibr(n-2)+fibr(n-1)); } int fibi(int n) { // Find nth Fibonacci number using iteration. int temp,last=1,f=1; int i; for (i=3;i&lt;n;++i) { // the first two Fibonacci numbers are 1 and 1 temp=f; f+=last; last=temp; } return f; }


Fibbomacci series using recursion shell programming?

Here is a good answer for recursion Fibonacci series. #include &lt;stdio.h&gt; #include &lt;conio.h&gt; long Fibonacci(long n); int main() { long r, n,i; printf("Enter the value of n: "); scanf("%ld",&amp;n); for(i=0;i&lt;=n;i++) { printf(" Fibonacci(%ld)= %ld\n", i,Fibonacci(i)); } getch(); return 0; } long Fibonacci(long n) { if(n==0 n==1) return n; else { return (Fibonacci(n-1)+Fibonacci(n-2)); } } for n=5; Output: Fibonacci(0)=0 Fibonacci(1)=1 Fibonacci(2)=1 Fibonacci(3)=2 Fibonacci(4)=3 Fibonacci(5)=5


Write a java program to print the last digit in Fibonacci series?

Just generate the Fibonacci numbers one by one, and print each number's last digit ie number%10.

Related questions

Can you have the program in C plus plus for recursive function generating a series of terms?

Yes, this can be done. For example for Fibonacci series. You will find plenty of examples if you google for the types of series you need to be generated.


Write a program to print the Fibonacci series in php upto input value using recursive function?

The Fibonacci sequence uses recursion to derive answers. It is defined as: F0 = 0 F1 = 1 Fn = F(n - 1) + F(n -2) To have this sequence printed by a php script use the following: function fibonacci($n) { if($n 1) return 1; //F1 else return fibonacci($n - 1) + fibonacci($n - 2); //Fn } This recursive function will print out the Fibonacci number for the integer n. To make it print out all the numbers in a particular set add this to your script. for($i = 0; $i &lt; 15; $i++) { echo fibonacci($i) . "&lt;br /&gt;"; } So your final result would look like. &lt;?php function fibonacci($n) { if($n 1) return 1; else return fibonacci($n - 1) + fibonacci($n - 2); } for($i = 0; $i &lt; 15; $i++) { echo fibonacci($i) . "&lt;br /&gt;"; } ?&gt;


Do grapes come under Fibonacci sequence?

No. Grapes have nothing to do with a recursive series of numbers following the rule that any number is the sum of the previous two.


Is 20 a Fibonacci number?

20 is not a term in the Fibonacci series.


What is recursive function?

A recursive function is one in which the value of a function at each point depends on its value at one or more previous points. A rercursive function requires the first few values to be defined normally - these are called bases. Perhaps one of the most famous recursive function is the Fibonacci series, which has f(1) = 1 f(2) = 1 f(n) = f(n-1) + f(n-2) for n = 3, 4, 5, ... There are two bases and each subsequent value is defined in terms of the preceding two.


What is the 100th number in the Fibonacci series?

It is 354224848179261915075.


What is Fibonacci number series?

A Fibonacci number series is like the example below, 1,1,2,3,5,8,13,21,34,55,89,144,233,377,610...... and so on in general Fibonacci numbers are just the previous two numbers added together starting with 1 and 0 then goes on forever.


What is the next number in the Fibonacci series?

The sum of the previous two numbers in the series.


How would one describe a Fibonacci number?

A Fibonacci number, Fibonacci sequence or Fibonacci series are a mathematical term which follow a integer sequence. The first two numbers in Fibonacci sequence start with a 0 and 1 and each subsequent number is the sum of the previous two.


What is the 10th number of a Fibonacci series starting at 1?

1,1,2,3,5,8,13,21,34,55


Is 1 the first number in the Fibonacci sequence?

According to the link, zero is the first number in the series.


What are the relations between the golden ratio and the Fibonacci series?

The ratio of successive terms in the Fibonacci sequence approaches the Golden ratio as the number of terms increases.