Cody

Problem 42340. Fibonacci Decomposition

Solution 2228110

Submitted on 22 Apr 2020 by Stefano sala
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 1; f_correct = 1; assert(isequal(fib_decomposition(n),f_correct))

g = 1 r = [] f = 1 1 r = 1 g = 0

2   Pass
n = 4; f_correct = [1 3]; assert(isequal(fib_decomposition(n),f_correct))

g = 4 r = [] f = 1 1 r = 3 g = 1 r = 1 3 g = 0

3   Pass
n = 6; f_correct = [1 5]; assert(isequal(fib_decomposition(n),f_correct))

g = 6 r = [] f = 1 1 r = 5 g = 1 r = 1 5 g = 0

4   Pass
n = 2010; f_correct = [2 34 377 1597]; assert(isequal(fib_decomposition(n),f_correct))

g = 2010 r = [] f = 1 1 r = 1597 g = 413 r = 377 1597 g = 36 r = 34 377 1597 g = 2 r = 2 34 377 1597 g = 0

5   Pass
n = 35601; f_correct = [1 34 144 6765 28657]; assert(isequal(fib_decomposition(n),f_correct))

g = 35601 r = [] f = 1 1 r = 28657 g = 6944 r = 6765 28657 g = 179 r = 144 6765 28657 g = 35 r = 34 144 6765 28657 g = 1 r = 1 34 144 6765 28657 g = 0

6   Pass
n = 9227467; f_correct = [2 9227465]; assert(isequal(fib_decomposition(n),f_correct))

g = 9227467 r = [] f = 1 1 r = 9227465 g = 2 r = 2 9227465 g = 0

7   Pass
n = 2015; f_correct = [2 5 34 377 1597]; assert(isequal(fib_decomposition(n),f_correct))

g = 2015 r = [] f = 1 1 r = 1597 g = 418 r = 377 1597 g = 41 r = 34 377 1597 g = 7 r = 5 34 377 1597 g = 2 r = 2 5 34 377 1597 g = 0

Suggested Problems

More from this Author50

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!