zeckendorf(N)

zeckendorf(N) using a greedy algorithm with binary exponentiation for computing Fib(n)
40 Downloads
Aktualisiert 8. Jun 2018

Lizenz anzeigen

Zeckendorf's theorem states that any positive integer, N, can be written as a sum of non-consecutive Fibonacci numbers uniquely. This is achieved by a greedy algorithm: the representation always starts with the largest Fibonacci number <= N.

Here, I used the definition of Fibonacci numbers as:
F(0) = 0
F(1) = 1
F(n) = F(n-1) + F(n-2).

For example: N = 100 = 89 + 8 + 3.

This code outputs the Zeckendorf representation of a positive integer N. Fibonacci numbers are computed using binary exponentiation of the Fibonacci matrix [1 1; 1 0].

Zitieren als

Karl Ezra Pilario (2024). zeckendorf(N) (https://www.mathworks.com/matlabcentral/fileexchange/67017-zeckendorf-n), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2017a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Number Theory finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.1.0.0

Added a bit string representation output.

1.0.0.0

Updated the description.