Homepage › Solution manuals › Ivan Niven › An Introduction to the Theory of Numbers › Exercise 4.4.14* (Zeckendorf representation of positive integers)
Exercise 4.4.14* (Zeckendorf representation of positive integers)
Consider the sequence . Prove that every positive integer has a unique representation as a sum of one or more distinct and non-consecutive terms of this sequence. Here two representations that differ only in the order of the summands are considered to be the same.
Answers
Proof. Let be a positive integer. We prove that there is a unique sequence of integers such that
where and for all indices .
Such a decomposition is named the Zeckendorf representation of (see Wikipedia).
-
Existence. We prove the existence of such a representation by induction. First, , so the property is true for . Now suppose that every positive integer less than has a Zeckendorf representation. We define as the largest integer such that , i.e.
Such an integer exists because , and the sequence is strictly increasing.
If , then has a Zeckendorf decomposition with one term. Otherwise, , thus
By the induction hypothesis, since , has a Zeckendorf representation
We define . Then .
Moreover, by (1), . Since is strictly increasing, , so is a Zeckendorf representation of . The induction is done, which proves that every positive integer has a Zeckendorf representation.
-
Unicity. We prove first that if is a Zeckendorf representation of , then
First .
Next, we proved in Problem 13 that for all positive integers ,
-
If is odd, say (where ), then using , we obtain
In particular, for , . Since is increasing
Since are distinct odd numbers in ,
Therefore .
-
If is even, say , then similarly
Therefore .
In both cases,
thus
There is only one Zeckendorf representation of , which is . Suppose that the Zeckendorf representation of any is unique. We want to show that the representation of is unique.
Assume that
are two Zeckendorf representations of . By the first part of the proof,
Then
are two Zeckendorf representations of . By the induction hypothesis and , so . There is only one Zeckendorf representation of .
The induction is done.
-
We can conclude:
There is a unique sequence of integers such that
where and for all indices . □
Note: Here is a non optimized Python program to compute the Zeckendorf representation of an integer (we calculate the Fibonacci numbers in each pass of the loop. It would be better to store them).
def Zeckendorf(n): l=[] while n != 0: f0, f1 = 0, 1 index = 0 while f1 <= n: f0, f1 = f1, f0 + f1 index += 1 l.append((index, f0)) n = n - f0 return l l = Zeckendorf(1234567891); l [(45, 1134903170), (39, 63245986), (37, 24157817), (35, 9227465), (32, 2178309), (30, 832040), (22, 17711), (19, 4181), (16, 987), (12, 144), (10, 55), (8, 21), (5, 5)] sum(elt[1] for elt in l) 1234567891
This means that