excuse m how to make a fibonacci equation ? dont know how its process nor what its doing ?
Printable View
excuse m how to make a fibonacci equation ? dont know how its process nor what its doing ?
Refused :confused:
The Fibonacci sequence is a recursive sequence of numbers. Just like the factorial value of a number is that number multiplied by the factorial value of the number before it, so the Fibonacci value of a number is the sum of the Fibonacci values of the two numbers before it.
That definition you posted is saying this:
1. The Fibonacci value of zero is defined as zero.
2. The Fibonacci value of 1 is defined as 1.
3. The Fibonacci value of any number n, where n is greater than 1, is n added to the Fibonacci value of (n - 1) added to the Fibonacci value of (n - 2).
Thus the Fibbonacci value of 2 is the sum of the Fibonacci value of 1 plus the Fibonacci value of zero. You know what they are from the definition. The Fibonacci value of 3 is the Fibonacci value of 2 plus the Fibonacci value of 1. Etc.
The only reason that I can think of that you'd be doing this is that you've been set an assignment to teach you how to implement recursion. In that case it is inappropriate for us to provide a code solution.
Do you know what recursion is for a start? It means that you implement a method that calls itself. You need to implement a method that takes a number and returns its Fibonacci value. You know from the above definition that if that number is zero you return zero, and if it's 1 you return 1. If it's any other number greater than 1 you return the sum of the Fibonacci values of the two numbers before it. That means that you'll have to call a method to get the Fibonacci values of those two numbers. You already have a method to do that because you're writing it yourself. That's the recursive part: Your method calls itself.
(~o~) .... looks hard ... but let me try it T_T .... (and oh this is not an assignment :) ... just practicing myself :wave: )
10 lines of code for the entire function declaration, and that includes a Select Case block.