Tool for encoding/decoding numbers using Fibonacci encoding (binary words never having two consecutive 1 values)
Fibonacci Encoding - dCode
Tag(s) : Compression, Mathematics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The Fibonacci code uses the Zeckendorf theorem (and Zeckendorf's representation of a number) which states that any integer can be written as the sum of non-consecutive Fibonacci numbers.
$$ n = \sum_{i=1}^{k} \beta_i F_{i} $$
The Fibonnacci coding consists in noting the coefficients $ \beta_i $ (being 0 or 1) to make a binary number.
Example: $ 123 $ is the sum of $ F_{11} = 89 $ and $ F_{9} = 34 $ or 1010000000 in binary (the two 1 are in position 8 and 10 starting from the right).
As the Zeckendorf representation never has 2 consecutive Fibonnacci numbers, the binary value will never have 2 times the number 1 consecutively.
Each 1 of the binary word corresponds to a Fibonacci number, to find the decimal number, add all the Fibonacci numbers corresponding to the 1 of the binary word.
Example: 10100 corresponds to $ 1 \times F_5 + 0 \times F_4 + 0 \times F_3 + 1 \times F_2 + 0 \times F_1 = F_5 + F_3 = 8 + 3 = 11 $
A variant of Zeckendorf's theorem indicates that it is also possible to write any integer as the sum of non-consecutive Nega-Fibonacci (Generalization of Fibonnacci with negative indices) numbers, this encoding is called NegaFibonacci encoding.
dCode retains ownership of the "Fibonacci Encoding" source code. Any algorithm for the "Fibonacci Encoding" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Fibonacci Encoding" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Fibonacci Encoding" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Fibonacci Encoding" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Fibonacci Encoding on dCode.fr [online website], retrieved on 2025-04-16,