# Zeckendorf's theorem

In mathematics, Zeckendorf's theorem, named after Belgian amateur mathematician Edouard Zeckendorf, is a theorem about the representation of integers as sums of Fibonacci numbers.
Zeckendorf's theorem states that every positive integer can be represented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive Fibonacci numbers. More precisely, if N is any positive integer, there exist positive integers c$_i$ ≥ 2, with c$_{i+1}$ > c$_i$ + 1, such that
    $N=\sum _{i=0}^{k}F_{c_{i}},$
where F$_n$ is the nth Fibonacci number. Such a sum is called the Zeckendorf representation of N. The Fibonacci coding of N can be derived from its Zeckendorf representation.
For example, the Zeckendorf representation of 64 is
    64 = 55 + 8 + 1.
There are other ways of representing 64 as the sum of Fibonacci numbers
    64 = 55 + 5 + 3 + 1
    64 = 34 + 21 + 8 + 1
    64 = 34 + 21 + 5 + 3 + 1
    64 = 34 + 13 + 8 + 5 + 3 + 1
but these are not Zeckendorf representations because 34 and 21 are consecutive Fibonacci numbers, as are 5 and 3.
For any given positive integer, its Zeckendorf representation can be found by using a greedy algorithm, choosing the largest possible Fibonacci number at each stage.

## History

While the theorem is named after the eponymous author who published his paper in 1972, the same result had been published 20 years earlier by Gerrit Lekkerkerker. As such, the theorem is an example of Stigler's Law of Eponymy.

## Proof

Zeckendorf's theorem has two parts:
* Existence: every positive integer n has a Zeckendorf representation.
* Uniqueness: no positive integer n has two different Zeckendorf representations.
The first part of Zeckendorf's theorem (existence) can be proven by induction. For n = 1, 2, 3 it is clearly true (as these are Fibonacci numbers), for n = 4 we have 4 = 3 + 1. If n is a Fibonacci number then there is nothing to prove. Otherwise there exists j such that F$_j$ < n < F$_{j+1}$ . Now suppose each positive integer a < n has a Zeckendorf representation (induction hypothesis) and consider b = n − F$_j$ . Since b < n, b has a Zeckendorf representation by the induction hypothesis. At the same time, b = n − F$_j$ < F$_{j+1}$ − F$_j$ = F$_{j−1}$  (we apply the definition of Fibonacci number in the last equality), so the Zeckendorf representation of b does not contain F$_{j−1}$ , and hence also does not contain F$_j$ . As a result, n can be represented as the sum of F$_j$ and the Zeckendorf representation of b, such that the Fibonacci numbers involved in the sum are distinct.
The second part of Zeckendorf's theorem (uniqueness) requires the following lemma:
    Lemma: The sum of any non-empty set of distinct, non-consecutive Fibonacci numbers whose largest member is F$_j$ is strictly less than the next larger Fibonacci number F$_{j+1}$ .
The lemma can be proven by induction on j.
Now take two non-empty sets $S$ and $T$ of distinct non-consecutive Fibonacci numbers which have the same sum, ∑$_{x∈S}$x=∑$_{x∈T}$x{\textstyle \sum _{x\in S}x=\sum _{x\in T}x}. Consider sets $S'$ and $T'$ which are equal to $S$ and $T$ from which the common elements have been removed (i. e. $S'=S\setminus T$ and $T'=T\setminus S$). Since $S$ and $T$ had equal sum, and we have removed exactly the elements from $S\cap T$ from both sets, $S'$ and $T'$ must have the same sum as well, ∑$_{x∈S′}$x=∑$_{x∈T′}$x{\textstyle \sum _{x\in S'}x=\sum _{x\in T'}x}.
Now we will show by contradiction that at least one of $S'$ and $T'$ is empty. Assume the contrary, i. e. that $S'$ and $T'$ are both non-empty and let the largest member of $S'$ be F$_s$ and the largest member of $T'$ be F$_t$. Because $S'$ and $T'$ contain no common elements, F$_s$ ≠ F$_t$. Without loss of generality, suppose F$_s$ < F$_t$. Then by the lemma, ∑$_{x∈S′}$x<F$_{s+1}${\textstyle \sum _{x\in S'}x<F_{s+1}}, and, by the fact that F$_s$<F$_{s+1}$≤F$_t${\textstyle F_{s}<F_{s+1}\leq F_{t}}, ∑$_{x∈S′}$x<F$_t${\textstyle \sum _{x\in S'}x<F_{t}}, whereas clearly ∑$_{x∈T′}$x≥F$_t${\textstyle \sum _{x\in T'}x\geq F_{t}}. This contradicts the fact that $S'$ and $T'$ have the same sum, and we can conclude that either $S'$ or $T'$ must be empty.
Now assume (again without loss of generality) that $S'$ is empty. Then $S'$ has sum 0, and so must $T'$. But since $T'$ can only contain positive integers, it must be empty too. To conclude: $S'=T'=\emptyset$ which implies $S=T$, proving that each Zeckendorf representation is unique.

## Fibonacci multiplication

One can define the following operation $a\circ b$ on natural numbers a, b: given the Zeckendorf representations $a=\sum _{i=0}^{k}F_{c_{i}}\;(c_{i}\geq 2)$ and $b=\sum _{j=0}^{l}F_{d_{j}}\;(d_{j}\geq 2)$ we define the Fibonacci product $a\circ b=\sum _{i=0}^{k}\sum _{j=0}^{l}F_{c_{i}+d_{j}}.$
For example, the Zeckendorf representation of 2 is $F_{3}$, and the Zeckendorf representation of 4 is $F_{4}+F_{2}$ ($F_{1}$ is disallowed from representations), so $2\circ 4=F_{3+4}+F_{3+2}=13+5=18.$
(The product is not always in Zeckendorf form. For example, $4\circ 4=(F_{4}+F_{2})\circ (F_{4}+F_{2})=F_{4+4}+2F_{4+2}+F_{2+2}=21+2\cdot 8+3=40=F_{9}+F_{5}+F_{2}.$)
A simple rearrangement of sums shows that this is a commutative operation; however, Donald Knuth proved the surprising fact that this operation is also associative.

## Representation with negafibonacci numbers

The Fibonacci sequence can be extended to negative index n using the rearranged recurrence relation
    $F_{n-2}=F_{n}-F_{n-1},$
which yields the sequence of "negafibonacci" numbers satisfying
    $F_{-n}=(-1)^{n+1}F_{n}.$
Any integer can be uniquely represented as a sum of negafibonacci numbers in which no two consecutive negafibonacci numbers are used. For example:
* −11 = F$_{−4}$ + F$_{−6}$ = (−3) + (−8)
* 12 = F$_{−2}$ + F$_{−7}$ = (−1) + 13
* 24 = F$_{−1}$ + F$_{−4}$ + F$_{−6}$ + F$_{−9}$ = 1 + (−3) + (−8) + 34
* −43 = F$_{−2}$ + F$_{−7}$ + F$_{−10}$ = (−1) + 13 + (−55)
* 0 is represented by the empty sum.
0 = F$_{−1}$ + F$_{−2}$ , for example, so the uniqueness of the representation does depend on the condition that no two consecutive negafibonacci numbers are used.
This gives a system of coding integers, similar to the representation of Zeckendorf's theorem. In the string representing the integer x, the nth digit is 1 if F$_{−n}$ appears in the sum that represents x; that digit is 0 otherwise. For example, 24 may be represented by the string 100101001, which has the digit 1 in places 9, 6, 4, and 1, because 24 = F$_{−1}$ + F$_{−4}$ + F$_{−6}$ + F$_{−9}$ . The integer x is represented by a string of odd length if and only if x > 0.