Cody

# Problem 42340. Fibonacci Decomposition

Solution 1909101

Submitted on 22 Aug 2019 by Eugene Avrutin
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))

first = 1 second = 0 sum = 0 count = 0 next = 0 next = 1 second = 1 first = 1 count = 1 sum = 1 n = 0 first = 1 second = 0 next = 0 f = 1 f = 1

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

first = 1 second = 0 sum = 0 count = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 count = 1 sum = 3 n = 1 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 count = 2 sum = 3 1 n = 0 first = 1 second = 0 next = 0 f = 3 1 f = 1 1 f = 1 3

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

first = 1 second = 0 sum = 0 count = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 count = 1 sum = 5 n = 1 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 count = 2 sum = 5 1 n = 0 first = 1 second = 0 next = 0 f = 5 1 f = 1 1 f = 1 5

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

first = 1 second = 0 sum = 0 count = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 next = 377 second = 233 first = 377 next = 610 second = 377 first = 610 next = 987 second = 610 first = 987 next = 1597 second = 987 first = 1597 next = 2584 second = 1597 first = 2584 count = 1 sum = 1597 n = 413 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 next = 377 second = 233 first = 377 next = 610 second = 377 first = 610 count = 2 sum = 1597 377 n = 36 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 count = 3 sum = 1597 377 34 n = 2 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 count = 4 sum = 1597 377 34 2 n = 0 first = 1 second = 0 next = 0 f = 1597 377 34 2 f = 2 377 34 2 f = 2 34 34 2 f = 2 34 377 2 f = 2 34 377 1597

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

first = 1 second = 0 sum = 0 count = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 next = 377 second = 233 first = 377 next = 610 second = 377 first = 610 next = 987 second = 610 first = 987 next = 1597 second = 987 first = 1597 next = 2584 second = 1597 first = 2584 next = 4181 second = 2584 first = 4181 next = 6765 second = 4181 first = 6765 next = 10946 second = 6765 first = 10946 next = 17711 second = 10946 first = 17711 next = 28657 second = 17711 first = 28657 next = 46368 second = 28657 first = 46368 count = 1 sum = 28657 n = 6944 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 next = 377 second = 233 first = 377 next = 610 second = 377 first = 610 next = 987 second = 610 first = 987 next = 1597 second = 987 first = 1597 next = 2584 second = 1597 first = 2584 next = 4181 second = 2584 first = 4181 next = 6765 second = 4181 first = 6765 next = 10946 second = 6765 first = 10946 count = 2 sum = 28657 6765 n = 179 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 count = 3 sum = 28657 6765 144 n = 35 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 count = 4 sum = 28657 6765 144 34 n = 1 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 count = 5 sum = 28657 6765 144 34 1 n = 0 first = 1 second = 0 next = 0 f = 28657 6765 144 34 1 f = 1 6765 144 34 1 f = 1 34 144 34 1 f = 1 34 144 34 1 f = 1 34 144 6765 1 f = 1 34 144 6765 28657

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

first = 1 second = 0 sum = 0 count = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 next = 377 second = 233 first = 377 next = 610 second = 377 first = 610 next = 987 second = 610 first = 987 next = 1597 second = 987 first = 1597 next = 2584 second = 1597 first = 2584 next = 4181 second = 2584 first = 4181 next = 6765 second = 4181 first = 6765 next = 10946 second = 6765 first = 10946 next = 17711 second = 10946 first = 17711 next = 28657 second = 17711 first = 28657 next = 46368 second = 28657 first = 46368 next = 75025 second = 46368 first = 75025 next = 121393 second = 75025 first = 121393 next = 196418 second = 121393 first = 196418 next = 317811 second = 196418 first = 317811 next = 514229 second = 317811 first = 514229 next = 832040 second = 514229 first = 832040 next = 1346269 second = 832040 first = 1346269 next = 2178309 second = 1346269 first = 2178309 next = 3524578 second = 2178309 first = 3524578 next = 5702887 second = 3524578 first = 5702887 next = 9227465 second = 5702887 first = 9227465 next = 14930352 second = 9227465 first = 14930352 count = 1 sum = 9227465 n = 2 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 count = 2 sum = 9227465 2 n = 0 first = 1 second = 0 next = 0 f = 9227465 2 f = 2 2 f = 2 9227465

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

first = 1 second = 0 sum = 0 count = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 next = 377 second = 233 first = 377 next = 610 second = 377 first = 610 next = 987 second = 610 first = 987 next = 1597 second = 987 first = 1597 next = 2584 second = 1597 first = 2584 count = 1 sum = 1597 n = 418 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 next = 89 second = 55 first = 89 next = 144 second = 89 first = 144 next = 233 second = 144 first = 233 next = 377 second = 233 first = 377 next = 610 second = 377 first = 610 count = 2 sum = 1597 377 n = 41 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 next = 13 second = 8 first = 13 next = 21 second = 13 first = 21 next = 34 second = 21 first = 34 next = 55 second = 34 first = 55 count = 3 sum = 1597 377 34 n = 7 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 next = 2 second = 1 first = 2 next = 3 second = 2 first = 3 next = 5 second = 3 first = 5 next = 8 second = 5 first = 8 count = 4 sum = 1597 377 34 5 n = 2 first = 1 second = 0 next = 0 next = 1 second = 1 first = 1 count = 5 sum = 1597 377 34 5 2 n = 0 first = 1 second = 0 next = 0 f = 1597 377 34 5 2 f = 2 377 34 5 2 f = 2 5 34 5 2 f = 2 5 34 5 2 f = 2 5 34 377 2 f = 2 5 34 377 1597