answersLogoWhite

0


Best Answer

Because the same calculations are done over and over again. Fib(n) - the nth. number in the sequence - is equal to fib(n-1) + fib(n-2). For example, fib(10) - the 10th. number in the sequence - is equal to fib(9) + fib(8). If you expand this, you get fib(8) + fib(7) + fib(7) + fib(6). If you expand again, you get fib(7) + fib(6) + fib(6) + fib(5) + fib(6) + fib(5) + fib(5) + fib(4). You can already see that some of the numbers have to be evaluated several times. In fact, the amount of calculations increases exponentially; whereas with a simple loop, to add numbers up to fib(n), this is not the case.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why recursive algorithm for Fibonacci series is inefficient?
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 < 15; $i++) { echo fibonacci($i) . "<br />"; } So your final result would look like. <?php function fibonacci($n) { if($n 1) return 1; else return fibonacci($n - 1) + fibonacci($n - 2); } for($i = 0; $i < 15; $i++) { echo fibonacci($i) . "<br />"; } ?>


How do you write a Fibonacci number sequence as a function in assembly language?

The process requires an understanding of the problem, understanding the tool, then the implementation in edit/test cycles. For example, you would want to understand the task first. Are you required to "write a Fibonacci number sequence" as a series of Fibonacci numbers in a range from A to B (e.g. 0, 1, 1, 2, 3, 5, 8), or are you required to create a tool that can create fib(N) for any argument N? What are the value constraints for N? Is the implementation of fib() required to support any number of N, including very large numbers or even infinity? The next step would be the selection of a suitable tool and algorithm. For example, one would want to use an assembly language based on its theoretically superior processing speed. (One might want to chose a higher-level programming language, for example in order to support portability of code to other processors.) The selection of the algorithm is also important. The mathematical definition of the Fibonacci number can be written as fib(N) = fib(N-1) + fib(N-2). These instructions naturally suggest a recursive algorithm, however, recursive algorithms are not suitable for very large arguments due to the resulting recursion depth. Since every recursive algorithm has an iterative equivalent, an iterative approach might be a better solution. Neither recursive nor iterative "brute force" implementations are suitable for very large arguments N, as the processing time is a function of N itself. Therefore, depending on the exact understanding of the problem, a different algorithm may need inventing. Once the problem and its preconditions are understood, the algorithm and programming language is chosen, the solution is implemented in edit/test cycles. This process is the same whether an assembly or a higher-level language is chosen. The exact sequence of the instructions in the chosen language depends on the choice of language, algorithm and the exact understanding of the problem. For assembly languages, the exact sequence of instructions further depend on the choice of one specific assembly language, given that each processor family has its own assembly language.


Algorithm of Fibonacci series in c?

#include<stdio.h> #include<conio.h> int fib(int a); main() { int a; clrscr(); scanf("%d",&a); for(int i=0;i<a;i++) printf("%d\n",fib(i)); } int fib(int a) { if(a==0) return 0; if(a==1) return 1; else return (fib(a-1)+fib(a-2)); }


Fibbomacci series using recursion shell programming?

Here is a good answer for recursion Fibonacci series. #include <stdio.h> #include <conio.h> long Fibonacci(long n); int main() { long r, n,i; printf("Enter the value of n: "); scanf("%ld",&n); for(i=0;i<=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


What are the features of algorithm?

An algorithm is just a description of a series of steps used to solve a specific problem.

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.


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.


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 < 15; $i++) { echo fibonacci($i) . "<br />"; } So your final result would look like. <?php function fibonacci($n) { if($n 1) return 1; else return fibonacci($n - 1) + fibonacci($n - 2); } for($i = 0; $i < 15; $i++) { echo fibonacci($i) . "<br />"; } ?>


Is 20 a Fibonacci number?

20 is not a term in the Fibonacci series.


code for fibonacci series in python?

Fibonacci sequence, also known as golden section sequence, is also known as "rabbit sequence" because mathematician Leonardoda Fibonacci introduced it by taking rabbit breeding as an example , refers to such a sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34,... Mathematically, Fibonacci sequence is defined recursively as follows: F (1) = 1, f (2) = 1, f (n) = f (n-1) + F (n-2) (n > = 2, n ∈ n *) The difficulty of Fibonacci sequence lies in the algorithm. If it becomes a generator, it needs to use the for loop to traverse the iteratable generator The first recursive method def fib_recur(n): assert n >= 0, "n > 0" if n


Who invent sEquence and series?

Fibonacci!


What is golden ratio in Fibonacci series?

As you expand the Fibonacci series, each new value in proportion to the previous approaches the Golden Ratio.


How do you write a Fibonacci number sequence as a function in assembly language?

The process requires an understanding of the problem, understanding the tool, then the implementation in edit/test cycles. For example, you would want to understand the task first. Are you required to "write a Fibonacci number sequence" as a series of Fibonacci numbers in a range from A to B (e.g. 0, 1, 1, 2, 3, 5, 8), or are you required to create a tool that can create fib(N) for any argument N? What are the value constraints for N? Is the implementation of fib() required to support any number of N, including very large numbers or even infinity? The next step would be the selection of a suitable tool and algorithm. For example, one would want to use an assembly language based on its theoretically superior processing speed. (One might want to chose a higher-level programming language, for example in order to support portability of code to other processors.) The selection of the algorithm is also important. The mathematical definition of the Fibonacci number can be written as fib(N) = fib(N-1) + fib(N-2). These instructions naturally suggest a recursive algorithm, however, recursive algorithms are not suitable for very large arguments due to the resulting recursion depth. Since every recursive algorithm has an iterative equivalent, an iterative approach might be a better solution. Neither recursive nor iterative "brute force" implementations are suitable for very large arguments N, as the processing time is a function of N itself. Therefore, depending on the exact understanding of the problem, a different algorithm may need inventing. Once the problem and its preconditions are understood, the algorithm and programming language is chosen, the solution is implemented in edit/test cycles. This process is the same whether an assembly or a higher-level language is chosen. The exact sequence of the instructions in the chosen language depends on the choice of language, algorithm and the exact understanding of the problem. For assembly languages, the exact sequence of instructions further depend on the choice of one specific assembly language, given that each processor family has its own assembly language.


Which areas of mathematics did Fibonacci specialize in?

Series


Algoritham of Fibonacci series 0112358..?

132134...


What is the 100th number in the Fibonacci series?

It is 354224848179261915075.


Who was a famous series whose mathematics occurs in nature?

The Fibonacci series.