Problem 2187. Generalized Fibonacci
The Fibonacci sequence is defined as:
Fib(1) = 0
Fib(2) = 1
Fib(N) = Fib(N-1) + Fib(N-2)
The Fibonacci sequence can be generalized as follows:
Fib_gen(1) = a
Fib_gen(2) = b
Fib_gen(N) = Fib_gen(N-1) + Fib_gen(N-2)
where 0 <= a <= b
Moreover it can be shown that
Fib_gen(N) = k(1) * Fib(N) + k(2) * Fib(N+1)
Given a and b find k(1) and k(2).
Solution Stats
Problem Comments
-
1 Comment
Rafael S.T. Vieira
on 4 Sep 2020
It is true that Fib_gen(N) = k(1) * Fib(N) + k(2) * Fib(N+1) for some k, but the problem is actually requesting Fib_gen(N) = k(2) * Fib(N) + k(1) * Fib(N-1) for another k. If one is still in doubt, generate the two sequences and look at the expected answer.
Solution Comments
Show commentsProblem Recent Solvers48
Suggested Problems
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1697 Solvers
-
Project Euler: Problem 9, Pythagorean numbers
1083 Solvers
-
Determine the number of odd integers in a vector
681 Solvers
-
Convert Two Character String into a Binary Vector
190 Solvers
-
205 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!