Cody

Problem 42340. Fibonacci Decomposition

Solution 1907354

Submitted on 21 Aug 2019 by Virtual AS
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))

f = 1 n = 0

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

f = 3 n = 1 f = 1 3 n = 0

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

f = 5 n = 1 f = 1 5 n = 0

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

f = 1597 n = 413 f = 377 1597 n = 36 f = 34 377 1597 n = 2 f = 2 34 377 1597 n = 0

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

f = 28657 n = 6944 f = 6765 28657 n = 179 f = 144 6765 28657 n = 35 f = 34 144 6765 28657 n = 1 f = 1 34 144 6765 28657 n = 0

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

f = 9227465 n = 2 f = 2 9227465 n = 0

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

f = 1597 n = 418 f = 377 1597 n = 41 f = 34 377 1597 n = 7 f = 5 34 377 1597 n = 2 f = 2 5 34 377 1597 n = 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!