Cody

Problem 47058. Determine the Zeckendorf expansion of a number

Solution 3439128

Submitted on 27 Oct 2020 at 16:12 by Tim
  • Size: 41
  • This is the leading solution.
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
x = 26; y_correct = [21 5]; assert(isequal(Zeckendorf(x),y_correct))

2   Pass
x = 26; y_correct = [21 5]; assert(isequal(Zeckendorf(x),y_correct))

3   Pass
x = 88; y_correct = [55 21 8 3 1]; assert(isequal(Zeckendorf(x),y_correct))

4   Pass
x = 965; y_correct = [610 233 89 21 8 3 1]; assert(isequal(Zeckendorf(x),y_correct))

5   Pass
x = 4180; y_correct = [2584 987 377 144 55 21 8 3 1]; assert(isequal(Zeckendorf(x),y_correct))

6   Pass
x = 75024; y_correct = [46368 17711 6765 2584 987 377 144 55 21 8 3 1]; assert(isequal(Zeckendorf(x),y_correct))

7   Pass
x = 514228; y_correct = [317811 121393 46368 17711 6765 2584 987 377 144 55 21 8 3 1]; assert(isequal(Zeckendorf(x),y_correct))

8   Pass
x = 514229; y_correct = 514229; assert(isequal(Zeckendorf(x),y_correct))

9   Pass
x = 8675309; y_correct = [5702887 2178309 514229 196418 75025 6765 1597 55 21 3]; assert(isequal(Zeckendorf(x),y_correct))

10   Pass
x = 2022243254; y_correct = [1836311903 165580141 14930352 3524578 1346269 514229 28657 6765 233 89 34 3 1]; assert(isequal(Zeckendorf(x),y_correct))

11   Pass
x = 314159265358; y_correct = [225851433717 86267571272 1836311903 165580141 24157817 9227465 3524578 1346269 75025 28657 6765 1597 144 8]; assert(isequal(Zeckendorf(x),y_correct))

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!