Cody

# Problem 42340. Fibonacci Decomposition

Solution 2032542

Submitted on 23 Nov 2019 by Hung Trinh
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))

d = 1.6180 b = [] k = 1 y = 1 f = 1 f = 1 y = 1 1 k = 2 f = 1 y = 1 1 1 k = 3 f = 2 y = 1 1 1 2 k = 4 y = 1 1 1 a = 0 b = 1 f = 1

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

d = 1.6180 b = [] k = 1 y = 1 f = 1 f = 1 y = 1 1 k = 2 f = 1 y = 1 1 1 k = 3 f = 2 y = 1 1 1 2 k = 4 f = 3.0000 y = 1 1 1 2 3 k = 5 f = 5.0000 y = 1 1 1 2 3 5 k = 6 y = 1 1 1 2 3 a = 1 b = 3 n = 1 y = 1 1 1 a = 0 b = 3 1 f = 1 3

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

d = 1.6180 b = [] k = 1 y = 1 f = 1 f = 1 y = 1 1 k = 2 f = 1 y = 1 1 1 k = 3 f = 2 y = 1 1 1 2 k = 4 f = 3.0000 y = 1 1 1 2 3 k = 5 f = 5.0000 y = 1 1 1 2 3 5 k = 6 f = 8.0000 y = 1 1 1 2 3 5 8 k = 7 y = 1 1 1 2 3 5 a = 1 b = 5 n = 1 y = 1 1 1 a = 0 b = 5 1 f = 1 5

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

d = 1.6180 b = [] k = 1 y = 1 f = 1 f = 1 y = 1 1 k = 2 f = 1 y = 1 1 1 k = 3 f = 2 y = 1 1 1 2 k = 4 f = 3.0000 y = 1 1 1 2 3 k = 5 f = 5.0000 y = 1 1 1 2 3 5 k = 6 f = 8.0000 y = 1 1 1 2 3 5 8 k = 7 f = 13.0000 y = 1 1 1 2 3 5 8 13 k = 8 f = 21.0000 y = 1 1 1 2 3 5 8 13 21 k = 9 f = 34.0000 y = 1 1 1 2 3 5 8 13 21 34 k = 10 f = 55.0000 y = 1 1 1 2 3 5 8 13 21 34 55 k = 11 f = 89.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 k = 12 f = 144.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 k = 13 f = 233.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 k = 14 f = 377.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 k = 15 f = 610.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 k = 16 f = 987.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 k = 17 f = 1.5970e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 18 377 610 987 1597 k = 18 f = 2.5840e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 19 377 610 987 1597 2584 k = 19 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 18 377 610 987 1597 a = 413 b = 1597 n = 413 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 a = 36 b = 1597 377 n = 36 y = 1 1 1 2 3 5 8 13 21 34 a = 2 b = 1597 377 34 n = 2 y = 1 1 1 2 a = 0 b = 1597 377 34 2 f = 2 34 377 1597

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

d = 1.6180 b = [] k = 1 y = 1 f = 1 f = 1 y = 1 1 k = 2 f = 1 y = 1 1 1 k = 3 f = 2 y = 1 1 1 2 k = 4 f = 3.0000 y = 1 1 1 2 3 k = 5 f = 5.0000 y = 1 1 1 2 3 5 k = 6 f = 8.0000 y = 1 1 1 2 3 5 8 k = 7 f = 13.0000 y = 1 1 1 2 3 5 8 13 k = 8 f = 21.0000 y = 1 1 1 2 3 5 8 13 21 k = 9 f = 34.0000 y = 1 1 1 2 3 5 8 13 21 34 k = 10 f = 55.0000 y = 1 1 1 2 3 5 8 13 21 34 55 k = 11 f = 89.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 k = 12 f = 144.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 k = 13 f = 233.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 k = 14 f = 377.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 k = 15 f = 610.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 k = 16 f = 987.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 k = 17 f = 1.5970e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 18 377 610 987 1597 k = 18 f = 2.5840e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 19 377 610 987 1597 2584 k = 19 f = 4.1810e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 20 377 610 987 1597 2584 4181 k = 20 f = 6.7650e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 21 377 610 987 1597 2584 4181 6765 k = 21 f = 1.0946e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 22 377 610 987 1597 2584 4181 6765 10946 k = 22 f = 1.7711e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 23 377 610 987 1597 2584 4181 6765 10946 17711 k = 23 f = 2.8657e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 24 377 610 987 1597 2584 4181 6765 10946 17711 28657 k = 24 f = 4.6368e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 25 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 k = 25 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 24 377 610 987 1597 2584 4181 6765 10946 17711 28657 a = 6944 b = 28657 n = 6944 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 21 377 610 987 1597 2584 4181 6765 a = 179 b = 28657 6765 n = 179 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 a = 35 b = 28657 6765 144 n = 35 y = 1 1 1 2 3 5 8 13 21 34 a = 1 b = 28657 6765 144 34 n = 1 y = 1 1 1 a = 0 b = 28657 6765 144 34 1 f = 1 34 144 6765 28657

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

d = 1.6180 b = [] k = 1 y = 1 f = 1 f = 1 y = 1 1 k = 2 f = 1 y = 1 1 1 k = 3 f = 2 y = 1 1 1 2 k = 4 f = 3.0000 y = 1 1 1 2 3 k = 5 f = 5.0000 y = 1 1 1 2 3 5 k = 6 f = 8.0000 y = 1 1 1 2 3 5 8 k = 7 f = 13.0000 y = 1 1 1 2 3 5 8 13 k = 8 f = 21.0000 y = 1 1 1 2 3 5 8 13 21 k = 9 f = 34.0000 y = 1 1 1 2 3 5 8 13 21 34 k = 10 f = 55.0000 y = 1 1 1 2 3 5 8 13 21 34 55 k = 11 f = 89.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 k = 12 f = 144.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 k = 13 f = 233.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 k = 14 f = 377.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 k = 15 f = 610.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 k = 16 f = 987.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 k = 17 f = 1.5970e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 18 377 610 987 1597 k = 18 f = 2.5840e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 19 377 610 987 1597 2584 k = 19 f = 4.1810e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 20 377 610 987 1597 2584 4181 k = 20 f = 6.7650e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 21 377 610 987 1597 2584 4181 6765 k = 21 f = 1.0946e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 22 377 610 987 1597 2584 4181 6765 10946 k = 22 f = 1.7711e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 23 377 610 987 1597 2584 4181 6765 10946 17711 k = 23 f = 2.8657e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 24 377 610 987 1597 2584 4181 6765 10946 17711 28657 k = 24 f = 4.6368e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 25 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 k = 25 f = 7.5025e+04 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 26 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 k = 26 f = 1.2139e+05 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 27 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 k = 27 f = 1.9642e+05 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 k = 28 f = 3.1781e+05 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Column 29 317811 k = 29 f = 5.1423e+05 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Columns 29 through 30 317811 514229 k = 30 f = 8.3204e+05 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Columns 29 through 31 317811 514229 832040 k = 31 f = 1.3463e+06 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Columns 29 through 32 317811 514229 832040 1346269 k = 32 f = 2.1783e+06 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Columns 29 through 33 317811 514229 832040 1346269 2178309 k = 33 f = 3.5246e+06 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Columns 29 through 34 317811 514229 832040 1346269 2178309 3524578 k = 34 f = 5.7029e+06 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Columns 29 through 35 317811 514229 832040 1346269 2178309 3524578 5702887 k = 35 f = 9.2275e+06 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 28 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 Columns 29 through 36 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 k = 36 f = 1.4930e+07 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 throug...

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

d = 1.6180 b = [] k = 1 y = 1 f = 1 f = 1 y = 1 1 k = 2 f = 1 y = 1 1 1 k = 3 f = 2 y = 1 1 1 2 k = 4 f = 3.0000 y = 1 1 1 2 3 k = 5 f = 5.0000 y = 1 1 1 2 3 5 k = 6 f = 8.0000 y = 1 1 1 2 3 5 8 k = 7 f = 13.0000 y = 1 1 1 2 3 5 8 13 k = 8 f = 21.0000 y = 1 1 1 2 3 5 8 13 21 k = 9 f = 34.0000 y = 1 1 1 2 3 5 8 13 21 34 k = 10 f = 55.0000 y = 1 1 1 2 3 5 8 13 21 34 55 k = 11 f = 89.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 k = 12 f = 144.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 k = 13 f = 233.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 k = 14 f = 377.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 k = 15 f = 610.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 k = 16 f = 987.0000 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 k = 17 f = 1.5970e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 18 377 610 987 1597 k = 18 f = 2.5840e+03 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 19 377 610 987 1597 2584 k = 19 y = Columns 1 through 14 1 1 1 2 3 5 8 13 21 34 55 89 144 233 Columns 15 through 18 377 610 987 1597 a = 418 b = 1597 n = 418 y = 1 1 1 2 3 5 8 13 21 34 55 89 144 233 377 a = 41 b = 1597 377 n = 41 y = 1 1 1 2 3 5 8 13 21 34 a = 7 b = 1597 377 34 n = 7 y = 1 1 1 2 3 5 a = 2 b = 1597 377 34 5 n = 2 y = 1 1 1 2 a = 0 b = 1597 377 34 5 2 f = 2 5 34 377 1597

### Community Treasure Hunt

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

Start Hunting!