Cody

Problem 42340. Fibonacci Decomposition

Solution 2974411

Submitted on 21 Sep 2020 by Albit
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))

list = 1 2 f = [] list = 1 n = 0 f = 1 list = 1×0 empty double row vector

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

list = 1 2 neu = 3 list = 1 2 3 neu = 5 list = 1 2 3 5 f = [] list = 1 2 3 n = 1 f = 3 list = 1 2 list = 1 n = 0 f = 1 3 list = 1×0 empty double row vector

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

list = 1 2 neu = 3 list = 1 2 3 neu = 5 list = 1 2 3 5 neu = 8 list = 1 2 3 5 8 f = [] list = 1 2 3 5 n = 1 f = 5 list = 1 2 3 list = 1 2 list = 1 n = 0 f = 1 5 list = 1×0 empty double row vector

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

list = 1 2 neu = 3 list = 1 2 3 neu = 5 list = 1 2 3 5 neu = 8 list = 1 2 3 5 8 neu = 13 list = 1 2 3 5 8 13 neu = 21 list = 1 2 3 5 8 13 21 neu = 34 list = 1 2 3 5 8 13 21 34 neu = 55 list = 1 2 3 5 8 13 21 34 55 neu = 89 list = 1 2 3 5 8 13 21 34 55 89 neu = 144 list = 1 2 3 5 8 13 21 34 55 89 144 neu = 233 list = 1 2 3 5 8 13 21 34 55 89 144 233 neu = 377 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 neu = 610 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 neu = 987 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 neu = 1597 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 16 987 1597 neu = 2584 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 17 987 1597 2584 f = [] list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 16 987 1597 n = 413 f = 1597 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 n = 36 f = 377 1597 list = 1 2 3 5 8 13 21 34 55 89 144 233 list = 1 2 3 5 8 13 21 34 55 89 144 list = 1 2 3 5 8 13 21 34 55 89 list = 1 2 3 5 8 13 21 34 55 list = 1 2 3 5 8 13 21 34 n = 2 f = 34 377 1597 list = 1 2 3 5 8 13 21 list = 1 2 3 5 8 13 list = 1 2 3 5 8 list = 1 2 3 5 list = 1 2 3 list = 1 2 n = 0 f = 2 34 377 1597 list = 1

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

list = 1 2 neu = 3 list = 1 2 3 neu = 5 list = 1 2 3 5 neu = 8 list = 1 2 3 5 8 neu = 13 list = 1 2 3 5 8 13 neu = 21 list = 1 2 3 5 8 13 21 neu = 34 list = 1 2 3 5 8 13 21 34 neu = 55 list = 1 2 3 5 8 13 21 34 55 neu = 89 list = 1 2 3 5 8 13 21 34 55 89 neu = 144 list = 1 2 3 5 8 13 21 34 55 89 144 neu = 233 list = 1 2 3 5 8 13 21 34 55 89 144 233 neu = 377 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 neu = 610 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 neu = 987 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 neu = 1597 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 16 987 1597 neu = 2584 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 17 987 1597 2584 neu = 4181 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 18 987 1597 2584 4181 neu = 6765 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 19 987 1597 2584 4181 6765 neu = 10946 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 20 987 1597 2584 4181 6765 10946 neu = 17711 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 21 987 1597 2584 4181 6765 10946 17711 neu = 28657 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 22 987 1597 2584 4181 6765 10946 17711 28657 neu = 46368 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 23 987 1597 2584 4181 6765 10946 17711 28657 46368 f = [] list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 22 987 1597 2584 4181 6765 10946 17711 28657 n = 6944 f = 28657 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 21 987 1597 2584 4181 6765 10946 17711 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 20 987 1597 2584 4181 6765 10946 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 19 987 1597 2584 4181 6765 n = 179 f = 6765 28657 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 18 987 1597 2584 4181 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 17 987 1597 2584 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 16 987 1597 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 list = 1 2 3 5 8 13 21 34 55 89 144 233 list = 1 2 3 5 8 13 21 34 55 89 144 n = 35 f = 144 6765 28657 list = 1 2 3 5 8 13 21 34 55 89 list = 1 2 3 5 8 13 21 34 55 list = 1 2 3 5 8 13 21 34 n = 1 f = 34 144 6765 28657 list = 1 2 3 5 8 13 21 list = 1 2 3 5 8 13 list = 1 2 3 5 8 list = 1 2 3 5 list = 1 2 3 list = 1 2 list = 1 n = 0 f = 1 34 144 6765 28657 list = 1×0 empty double row vector

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

list = 1 2 neu = 3 list = 1 2 3 neu = 5 list = 1 2 3 5 neu = 8 list = 1 2 3 5 8 neu = 13 list = 1 2 3 5 8 13 neu = 21 list = 1 2 3 5 8 13 21 neu = 34 list = 1 2 3 5 8 13 21 34 neu = 55 list = 1 2 3 5 8 13 21 34 55 neu = 89 list = 1 2 3 5 8 13 21 34 55 89 neu = 144 list = 1 2 3 5 8 13 21 34 55 89 144 neu = 233 list = 1 2 3 5 8 13 21 34 55 89 144 233 neu = 377 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 neu = 610 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 neu = 987 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 neu = 1597 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 16 987 1597 neu = 2584 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 17 987 1597 2584 neu = 4181 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 18 987 1597 2584 4181 neu = 6765 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 19 987 1597 2584 4181 6765 neu = 10946 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 20 987 1597 2584 4181 6765 10946 neu = 17711 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 21 987 1597 2584 4181 6765 10946 17711 neu = 28657 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 22 987 1597 2584 4181 6765 10946 17711 28657 neu = 46368 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 23 987 1597 2584 4181 6765 10946 17711 28657 46368 neu = 75025 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 24 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 neu = 121393 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 25 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 neu = 196418 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 26 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 neu = 317811 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 27 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 neu = 514229 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 neu = 832040 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Column 29 832040 neu = 1346269 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Columns 29 through 30 832040 1346269 neu = 2178309 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Columns 29 through 31 832040 1346269 2178309 neu = 3524578 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Columns 29 through 32 832040 1346269 2178309 3524578 neu = 5702887 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Columns 29 through 33 832040 1346269 2178309 3524578 5702887 neu = 9227465 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Columns 29 through 34 832040 1346269 2178309 3524578 5702887 9227465 neu = 14930352 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Columns 29 through 35 832040 1346269 2178309 3524578 5702887 9227465 14930352 f = [] list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Columns 29 through 34 832040 1346269 2178309 3524578 5702887 9227465 n = 2 f = 9227465 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 28 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Co...

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

list = 1 2 neu = 3 list = 1 2 3 neu = 5 list = 1 2 3 5 neu = 8 list = 1 2 3 5 8 neu = 13 list = 1 2 3 5 8 13 neu = 21 list = 1 2 3 5 8 13 21 neu = 34 list = 1 2 3 5 8 13 21 34 neu = 55 list = 1 2 3 5 8 13 21 34 55 neu = 89 list = 1 2 3 5 8 13 21 34 55 89 neu = 144 list = 1 2 3 5 8 13 21 34 55 89 144 neu = 233 list = 1 2 3 5 8 13 21 34 55 89 144 233 neu = 377 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 neu = 610 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 neu = 987 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 neu = 1597 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 16 987 1597 neu = 2584 list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 17 987 1597 2584 f = [] list = Columns 1 through 14 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Columns 15 through 16 987 1597 n = 418 f = 1597 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 610 list = 1 2 3 5 8 13 21 34 55 89 144 233 377 n = 41 f = 377 1597 list = 1 2 3 5 8 13 21 34 55 89 144 233 list = 1 2 3 5 8 13 21 34 55 89 144 list = 1 2 3 5 8 13 21 34 55 89 list = 1 2 3 5 8 13 21 34 55 list = 1 2 3 5 8 13 21 34 n = 7 f = 34 377 1597 list = 1 2 3 5 8 13 21 list = 1 2 3 5 8 13 list = 1 2 3 5 8 list = 1 2 3 5 n = 2 f = 5 34 377 1597 list = 1 2 3 list = 1 2 n = 0 f = 2 5 34 377 1597 list = 1

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!