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 1 , 2 , 3 , 5 , 8 , = F 2 , F 3 , F 4 , F 5 , F 6 , . 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 n be a positive integer. We prove that there is a unique sequence of integers ( j 0 , j 1 , , j k ) such that

n = F j 0 + F j 1 + + F j k ,

where 2 j 0 and j i + 1 > j i + 1 for all indices i [ [ 0 , k [ [ .

Such a decomposition is named the Zeckendorf representation of n (see Wikipedia).

  • Existence. We prove the existence of such a representation by induction. First, 1 = F 2 , so the property is true for n = 1 . Now suppose that every positive integer less than n has a Zeckendorf representation. We define j as the largest integer such that F j n ( j 2 ) , i.e.

    j = max { i { 0 , 1 } F i n } .

    Such an integer exists because F 2 = 1 , and the sequence ( F i ) i 2 is strictly increasing.

    If F j = n , then n has a Zeckendorf decomposition with one term. Otherwise, F j < n < F j + 1 , thus

    0 < n F j < F j + 1 F j = F j 1 . (1)

    By the induction hypothesis, since 1 n F j < n , n F j has a Zeckendorf representation

    n F j = F j 0 + F j 1 + + F j k , 2 j 0 , j i + 1 > j i + 1 ( i = 0 , 1 , k 1 ) .

    We define j k + 1 = j . Then n = F j 0 + F j 1 + + F j k + F j k + 1 .

    Moreover, by (1), F j k n F j < F j 1 . Since ( F i ) i 2 is strictly increasing, j k < j 1 = j k + 1 1 , so n = F j 0 + F j 1 + + F j k + F j k + 1 is a Zeckendorf representation of n . The induction is done, which proves that every positive integer has a Zeckendorf representation.

  • Unicity. We prove first that if n = F j 0 + F j 1 + + F j k is a Zeckendorf representation of n , then j k = max { i { 0 , 1 } F i n } .

    First F j k l = 0 k F j l = n .

    Next, we proved in Problem 13 that for all positive integers m ,

    F 2 m = F 1 + F 3 + + F 2 m 1 , (2) F 2 m + 1 = 1 + F 2 + F 4 + + F 2 m . (3)
    • If j k is odd, say j = 2 m 1 (where m 2 ), then using j i j i + 1 2 , we obtain

      j k 1 j k 2 , j k 2 j k 4 , , j k i j k 2 i ( i = 0 , 1 , , k ) .

      In particular, for i = k , 2 j 0 j k 2 k . Since ( F i ) i 2 is increasing

      n = F j 0 + F j 1 + + F j k F j k 2 k + F j k 2 ( k 1 ) + + F j k .

      Since j k , j k 2 , , j k 2 k are distinct odd numbers in ] ] 2 , 2 m [ [ ,

      n F 3 + F 5 + + F 2 m 1 = F 2 m 1 ( by (2) ) .

      Therefore n < F 2 m = F j k + 1 .

    • If j k is even, say j k = 2 m , then similarly

      n = F j 0 + F j 1 + + F j k F j k 2 k + F j k 2 ( k 1 ) + + F j k F 2 + F 4 + + F 2 m = F 2 m + 1 1 ( by (3) )

      Therefore n < F 2 m + 1 = F j k + 1 .

    In both cases,

    F j k n < F j k + 1 ,

    thus

    j k = max { i { 0 , 1 } F i n } .

    There is only one Zeckendorf representation of 1 , which is 1 = F 2 . Suppose that the Zeckendorf representation of any m < n is unique. We want to show that the representation of n is unique.

    Assume that

    n = F j 0 + F j 1 + + F j k = F l 0 + F l 1 + + F l p

    are two Zeckendorf representations of n . By the first part of the proof,

    F j k = max { i { 0 , 1 } F i n } = F l p .

    Then

    n F j k = F j 0 + F j 1 + + F j k 1 = F l 0 + F l 1 + + F l p 1

    are two Zeckendorf representations of m = n F j k < n . By the induction hypothesis k = p and ( j 0 , j 1 , , j k 1 ) = ( l 0 , l 1 , , l p 1 ) , so ( j 0 , j 1 , , j k ) = ( l 0 , l 1 , , l p ) . There is only one Zeckendorf representation of n .

    The induction is done.

We can conclude:

There is a unique sequence of integers ( j 0 , j 1 , , j k ) such that

n = F j 0 + F j 1 + + F j k ,

where 2 j 0 and j i + 1 > j i + 1 for all indices i [ [ 0 , k [ [ . □

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

1234567891 = F 5 + F 8 + F 10 + F 12 + F 16 + F 19 + F 22 + F 30 + F 32 + F 35 + F 37 + F 39 + F 45 = 5 + 21 + 55 + 144 + 987 + 4181 + 17711 + 832040 + 2178309 + 9227465 + 24157817 + 63245986 + 1134903170 .
User profile picture
2025-02-21 11:24
Comments