Cody

# Problem 42340. Fibonacci Decomposition

Solution 1977790

Submitted on 15 Oct 2019 by Joseph Chambers
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))

adding first fib number, largest one first ans = 2 calc length of fib series helpend = 1 inside loop ans = 2 f = 2 f = 1

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

adding first fib number, largest one first ans = 3 calc length of fib series helpend = 2 inside loop adding a number to answer, equal to N ans = 3 1 f = 1 3

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

adding first fib number, largest one first ans = 5 calc length of fib series helpend = 3 inside loop inside loop adding a number to answer, equal to N ans = 5 1 f = 1 5

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

adding first fib number, largest one first ans = 1597 calc length of fib series helpend = 15 inside loop inside loop adding a number to answer, still less than N inside loop inside loop inside loop inside loop inside loop adding a number to answer, still less than N inside loop inside loop inside loop inside loop inside loop inside loop adding a number to answer, equal to N ans = 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))

adding first fib number, largest one first ans = 28657 calc length of fib series helpend = 21 inside loop inside loop adding a number to answer, still less than N inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop adding a number to answer, still less than N inside loop inside loop inside loop adding a number to answer, still less than N inside loop inside loop inside loop inside loop inside loop inside loop inside loop adding a number to answer, equal to N ans = 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))

adding first fib number, largest one first ans = 9227465 calc length of fib series helpend = 33 inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop inside loop adding a number to answer, equal to N ans = 9227465 2 f = 2 9227465

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

adding first fib number, largest one first ans = 1597 calc length of fib series helpend = 15 inside loop inside loop adding a number to answer, still less than N inside loop inside loop inside loop inside loop inside loop adding a number to answer, still less than N inside loop inside loop inside loop inside loop adding a number to answer, still less than N inside loop inside loop adding a number to answer, equal to N ans = 1597 377 34 5 2 f = 2 5 34 377 1597