30
SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONS TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE Abstract. We investigate representations of natural numbers in terms of rational bases. We then define a collection of combinato- rial data associated with a rational number and describe the prop- erties of these data. We use this combinatorial data to construct an infinite, labeled, rooted tree and prove that it contains many of the interesting features of the relevant rational base representations of natural numbers. We also explore some of the combinatorics of these trees as well as the rational base representations of interest. Our main result is an analog of Kummer’s theorem for rational bases representations in terms of generalized binomial coefficients defined in terms of sequences generated from the previously men- tioned rooted trees. Introduction In [4] and [5], many connections are established between base-b rep- resentations of numbers, number theory, and some associated combi- natorial objects. In an attempt to generalize those results to rational base representations of numbers, we encountered some difficulties. In rectifying the difficulties, we learned a great deal about these ratio- nal base representations and different combinatorial objects associated with them. We explore some known connections between rational base representations of natural numbers elementary number theory by pro- viding a simple construction of a class of infinite, rooted trees. With these objects understood, we are able to generalize the main result of [4] to rational bases. The preliminary section provides the appropriate background nec- essary to discuss our main result. Many of the results we include are already known; they either appear in [2], [9], [3], or [15] or are conse- quences of results therein. As these results are spread out over many papers, we provide proofs for completeness. We begin by introducing our chosen notion of a p q -representation of a natural number, which can Date : April 14, 2017. 2010 Mathematics Subject Classification. 11A63, 11A67, 11B75 and 05C05. 1

SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

SOME COMBINATORICS OF RATIONAL BASEREPRESENTATIONS

TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Abstract. We investigate representations of natural numbers interms of rational bases. We then define a collection of combinato-rial data associated with a rational number and describe the prop-erties of these data. We use this combinatorial data to construct aninfinite, labeled, rooted tree and prove that it contains many of theinteresting features of the relevant rational base representations ofnatural numbers. We also explore some of the combinatorics ofthese trees as well as the rational base representations of interest.Our main result is an analog of Kummer’s theorem for rationalbases representations in terms of generalized binomial coefficientsdefined in terms of sequences generated from the previously men-tioned rooted trees.

Introduction

In [4] and [5], many connections are established between base-b rep-resentations of numbers, number theory, and some associated combi-natorial objects. In an attempt to generalize those results to rationalbase representations of numbers, we encountered some difficulties. Inrectifying the difficulties, we learned a great deal about these ratio-nal base representations and different combinatorial objects associatedwith them. We explore some known connections between rational baserepresentations of natural numbers elementary number theory by pro-viding a simple construction of a class of infinite, rooted trees. Withthese objects understood, we are able to generalize the main result of[4] to rational bases.

The preliminary section provides the appropriate background nec-essary to discuss our main result. Many of the results we include arealready known; they either appear in [2], [9], [3], or [15] or are conse-quences of results therein. As these results are spread out over manypapers, we provide proofs for completeness. We begin by introducingour chosen notion of a p

q-representation of a natural number, which can

Date: April 14, 2017.2010 Mathematics Subject Classification. 11A63, 11A67, 11B75 and 05C05.

1

Page 2: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

2 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

be found in [9]; it is well known that every natural number has a uniquesuch representation when p and q are relatively prime. These represen-tations differ from those described in [18] as we use a different digit setaltogether; they also differ slightly from the main representations givenin [2] and [17]. We also include few results pertaining to performingarithmetic with these representations and include an analogs of clas-sical results about the sum-of-digits function and the length function.Next, we describe a collection of combinatorial data uniquely deter-mined by a pair of relatively prime natural numbers that we call apq-branch sequence. We explain a method similar to the Euclidean

Algorithm to compute these sequences and their associated cobranchsequences. As it turns out, these sequences are closely related to ideasthat have already been extensively studied. Since our objects differslightly, we provide proofs of results that are well known in the othercontexts but may not have been applied explicitly to the sequences inthe form we describe. As a side note, we explore a connection betweenbranch sequences and a famous binary tree from number theory calledthe Stern-Brocot tree.

In Section 2, we employ the properties of branch sequences to con-struct an infinite, labeled, rooted tree in two different ways. The firstconstruction is basically the same as the one given in [2] and [9] whereit is used to describe an alternate family of rational base expansions.We then provide a simple combinatorial construction of the same treeand prove these two trees are the same. While we believed this combi-natorial construction to be new, we have since been notified that ourconstruction is equivalent to the recent construction of trees in [16];nonetheless, we include our construction as it was discovered indepen-dently. Finally, we provide proofs of known results that this tree allowsus to determine if a sequence of digits corresponds to a p

q-representation

of a natural number. As a byproduct, we produce a formula for findingany given digit of a representation and characterize the numbers thatare divisible by q.

Section 3 contains our main result. We discuss the motivation forthis work by introducing the dominance order on N arising from p

q-

representations. We utilize our understanding of pq-representations and

the associated trees to to provide a few results analogous to those in[4] and [5]. In particular, we introduce a family of generalized binomialcoefficients (as described in [13]) and use these coefficients to prove ananalog of famous theorem due to Kummer for p

q-arithmetic.

For a detailed treatment about various positional numeral systemssee [12], [14], or [10].

Page 3: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 3

1. Preliminaries and Background

As mentioned in the introduction, most of the results in this sectioncan be found in, or are consequences of results from, [2], [9], [3], or [15].However, our proofs are entirely elementary, requiring no backgroundbeyond standard undergraduate courses.

pq-representations of natural numbers. For each b ∈ N with b ≥ 2,

we let Ab = {0, 1, ..., b − 1} and call this the digit set for b. Next, welet

Sb = {(a0, a1, a2, ...) | ai ∈ Ab and ai = 0 for all but finitely many i}.

For ease of notation, we write elements of Sb as (a0, a1, ..., ak) where kis the largest index with ak 6= 0. For s = (a0, a1, . . . , ak) ∈ Sb, we saythat s has length k and write len(s) = k.

Now, let p, q ∈ N with p > q ≥ 1. We define the (p, q)-evaluationmap ep,q : Sp → Q by

ep,q((a0, a1, ..., ak)) =k∑

i=0

ai

(p

q

)i

.

For any n ∈ N, we say (a0, a1, . . . , ak) ∈ Sp is a pq-representation

for n if ep,q((a0, a1, . . . , ak)) = n, and we will denote this by n =(a0, a1, . . . ak) p

q. See A024629-40 in [1] for various examples. When

q = 1, this is the standard definition of a base-p representation ofa natural number. Moreover, each natural number has a unique p

1-

representation. We extend this result as follows.

Theorem 1.1. For every p, q ∈ N with p > q ≥ 1 and gcd(p, q) = 1;each n ∈ N has a unique p

q-representation.

Proof. The existence of these representations follows by induction and

the fact that p(

pq

)i= q

(pq

)i+1

.

The common proof of uniqueness is as follows. We assume, for thesake of contradiction, that n has two distinct p

q-representations n =

(a0, a1, . . . , am) pq

and n = (b0, b1, . . . , bs) pq

so that ai, bi ∈ {0, 1, ..., p−1}for all i. Assume m ≤ s, and let j be the minimal index where aj 6= bj.Then, it follows that

0 =m∑i=0

ai

(p

q

)i

−s∑

i=0

bi

(p

q

)i

.

Page 4: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

4 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Now, since ai = bi for all i < j we get

0 = (aj − bj)(p

q

)j

+s∑

i=j+1

(ai − bi)(p

q

)i

.

Dividing each term by(

pq

)jand multiplying by qs−j leaves us with

0 = qs−j(aj − bj) +s∑

i=j+1

(aj − bj)(p)i−jqs−i.

Since s ≥ i > j for all i, we know that this is an integral equation.Therefore 0 = qs−j(aj − bj) (mod p). Now, the fact that gcd(p, q) = 1implies that

0 = aj − bj (mod p),

and so aj = bj (mod p); however, since aj, bj ∈ {0, 1, ..., p − 1}, thismeans aj = bj, which is a contradiction. �

Example 1.2. Let p = 3 and q = 2. Then the following table liststhe 3

2-representations of the integers from 0 to 21 (we have omitted

subscripts for aesthetics). See A024629 in [1] for more data.

n 32-representation

0 (0)

1 (1)

2 (2)

3 (0,2)

4 (1,2)

5 (2,2)

6 (0,1,2)

7 (1,1,2)

8 (2,1,2)

9 (0,0,1,2)

10 (1,0,1,2)

n 32-representation

11 (2,0,1,2)

12 (0,2,1,2)

13 (1,2,1,2)

14 (2,2,1,2)

15 (0,1,0,1,2)

16 (1,1,0,1,2)

17 (2,1,0,1,2)

18 (0,0,2,1,2)

19 (1,0,2,1,2)

20 (2,0,2,1,2)

21 (0,2,2,1,2)

For example, 1(32)0+0(3

2)1+1(3

2)2+2(3

2)3 = 10 and so 10 = (1, 0, 1, 2) 3

2.

Page 5: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 5

Remark. The uniqueness of Theorem 1.1 requires p and q to be rel-atively prime. For example 25 = (5, 4) 10

2and 25 = (0, 5) 10

2. Conse-

quently, for the rest of the paper, we will only consider the cases wherep and q are relatively prime.

Of course, the pq-representation of n+m can be generated from the

representations of n and m separately. More precisely, suppose thatn,m ∈ N with n = (n0, n1, . . . , nk) p

qand m = (m0,m1 . . . ,ms) p

q. We

first define the (pq, n,m)-carry sequence recursively by

εpq,n,m

i =

⌊ni +mi + qεi−1

p

⌋,

where we set εpq,n,m

−1 = 0. When the context is understood, we will omitthe superscripts. Using this carry sequence, the p

q-representation of

n+m is given by

(1) (n+m)i = ni +mi + qεi−1 − pεi.

The formula listed in Equation (1) provides us with a system of base-pq

arithmetic. We mention two interesting features of this arithmeticsystem.

Proposition 1.3. Let n,m, p, q ∈ N with p > q ≥ 1 and gcd(p, q) = 1.For all i ∈ N

εpq,n,m

i ≤ q.

Proof. By definition ε−1 = 0 ≤ q. Assume εi−1 ≤ q. Then

ni + ki + qεi−1p

≤ 2(p− 1) + q2

p=

2p+ q2 − 2

p<

2p+ pq − pp

= q + 1,

where the last inequality holds since q2 − 2 < pq − p for all p > q ≥ 1.Since the inequality is strict, we see that

εi =

⌊ni +mi + qεi−1

p

⌋≤ q.

The result follows by induction. �

Thus there is a bound on the size of carries we must keep track ofwhile adding two numbers. This proposition is a consequence of [2] thataddition in this arithmetic can be realized by a finite state automaton.

The next proposition provides a formula for determining the totalnumber of carries when adding two numbers in base-p

qarithmetic. To

do this we define the pq-sum-of-digits function by sum p

q(n) =

∑ki=0 ni

Page 6: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

6 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

when n = (n0, n1, . . . , nk) pq. For examples of these functions, see

A244040-41, A245336-39 in [1].

Proposition 1.4. Let p, q ∈ N with p > q and gcd(p, q) = 1. For alln,m ∈ N

sum pq(n) + sum p

q(m)− sum p

q(n+m) = (p− q)

t∑i=0

εi

where t is the largest index such that (n+m)t is nonzero.

Proof. We assume n = (n0, n1, . . . , ns) pq, m = (m0,m1, . . . ,mu) and

n + m = ((n + m)0, (n + m)1, . . . , (n + m)t) where ni,mi, (n + m)i ∈{0, 1, ..., p− 1} for all i and t ≥ u ≥ s. Then substituting Equation (1)into sum p

q(n) + sum p

q(m)− sum p

q(n+m) yields

s∑i=0

ni +u∑

i=0

mi −t∑

i=0

(ni +mi + qεi−1 − pεi).

After canceling appropriate terms and reorganizing, this is equal to

−q(ε−1 + ε0 + · · ·+ εt−1) + p(ε0 + ε1 + · · ·+ εt).

Since ε−1 = εt = 0, we conclude

sum pq(n) + sum p

q(m)− sum p

q(n+m) = (p− q)(ε0 + · · ·+ εt−1 + εt)

as required. �

When q = 1, this is a classical result about the sum of digits thatdemonstrates the interconnected nature of number theory, algebraiccombinatorics, and enumerative combinatorics (see [4]).

Since every natural number has a unique pq-representation, we let

len pq(n) = k when n = (n0, n1, . . . , nk) p

q. Proposition 1.3 provides a

bound on the length of n + m in terms of n and m, implies that 0 ≤len p

q(n) − len p

q(n − 1) ≤ 1. We are particularly interested in the case

where len pq(n)− len p

q(n− 1) = 1; when n has this property we refer to

n as a knockout carry (because when n− 1 and 1 are added, each digitis reduced by q, except for the first digit which is reduced by p− 1 to0). To describe the knockout carries, we let g0 : N→ N be the function

g0(n) = p

⌈n

q

⌉.

This function will also be important in Section 2.Based on results in [2] or by direct computation we see that if n is a

knockout carry then g0(n) is the smallest knockout carry greater thann. The following proposition is then immediate.

Page 7: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 7

Proposition 1.5. The sequence of knockout carries (k1, k2, k3, . . .) isdetermined by k1 = 1 and ki = g0(ki−1) for all i > 1. Moreover, if cnis the number of nonnegative integers with length n, then for n > 1,cn = kn+1 − kn.

For an example of these two different types of sequences when p = 3and q = 2, see A070885 and A081848 in [1].

In [5] the authors describe in detail a partial order defined in terms ofbase-b representations where b ∈ N. In this special case, every sequencein Sb corresponds to a natural number under the (b, 1)-evaluation map.Unfortunately, this is not true for p

q-representations in general. As such,

the associated partial order, defined in Section 3, is more complicatedto understand because it requires us to know which sequences in Sp

correspond to natural numbers. In [2] and [9], the authors define aninfinite, rooted tree that characterizes their corresponding rational baserepresentations. In the following subsections, we introduce a family ofcombinatorial data that we will use to give a purely combinatorialconstruction of the same tree in Section 2.

pq-branch sequences. For this section, we fix two natural numbers, p

and q, satisfying p > q ≥ 1 and gcd(p, q) = 1. We begin by introducinga collection of combinatorial data that we call a p

q-branch sequence. It

turns out that pq-branch sequences are closely related to well-studied

notions such as Euclidean strings, Christoffel words, and Sturmian se-quences (see [8], [6], [7]). Furthermore, after completion of this projectwe learned that much of this information has been given independentlyin [16]. Nonetheless, we include our construction and (re)prove someproperties that are known about those objects for completeness.

We let t be the sequence t = (t1, ..., tq+1) given by ti =⌈ipq

⌉(t is

actually an infinite sequence that we truncate and is sometimes referredto as a Beatty sequence, see A007494 in [1] for instance). Then, wedefine the p

q-branch sequence to be b = (b1, ...bq) where bi = ti+1 − ti.

We will use bold letters to represent branch sequences in order todifferentiate them from p

q-representations. Technically, the sequence b

just defined can be thought of as an infinite, periodic sequence withperiod q; we may often refer to bk when k > q, in which case wemean b(k mod q). For example, see A040001 and A107453 in [1] forthe 3

2- and 5

4-branch sequences respectively. Each number ti counts

the multiples of q strictly less than ip including 0. Consequently, bicounts the multiples of q between ip and (i+ 1)p including ip if ip = 0(mod q). Moreover, the following properties are satisfied by the p

q-

branch sequence.

Page 8: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

8 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Proposition 1.6. Let b = (b1, ..., bq) be the pq-branch sequence. Then

the following hold.

(1) If q = 1, b = (p),(2) the sum of the entries is p, i.e.

∑qi=1 bi = p,

(3) for all i,⌊pq

⌋≤ bi ≤

⌈pq

⌉,

(4) the penultimate entry bq−1 =⌊pq

⌋, and

(5) the final entry bq =⌈pq

⌉.

Proof. Part (1) follows directly from the definition. For part (2), we

have∑q

i=1 bq = tq+1 − t1 =⌈(q+1)p

q

⌉−⌈pq

⌉= p+

⌈pq

⌉−⌈pq

⌉= p. Now,

for part (3), we note that 1− {x} = dxe − x where {x} represents thefractional part of x. Using this result, we get

bi =

⌈(i+ 1)p

q

⌉−⌈ip

q

⌉=

⌈ip

q

⌉+

⌈p

q

⌉+

⌈{ip

q

}+

{p

q

}⌉− 2−

⌈ip

q

⌉.

Then, since 1 ≤⌈{

ipq

}+{

pq

}⌉≤ 2, we have

⌈pq

⌉− 1 ≤ bi ≤

⌈pq

⌉, as

required. For parts (4) and (5) we see that

bq−1 =

⌈qp

q

⌉−⌈

(q − 1)p

q

⌉= −

⌈−pq

⌉=

⌊p

q

⌋,

and

bq =

⌈(q + 1)p

q

⌉−⌈qp

q

⌉=

⌈p

q

⌉,

where both follow from the fact that dn+xe = n+dxe when n ∈ N. �

We can also determine the branch sequence in a purely number the-oretic manner using a computationally simple process similar to theEuclidean Algorithm. We describe this process in the following lemma.

Lemma 1.7. The pq-branch sequence b = (b1, ..., bq) is the unique finite

sequence of numbers satisfying the following system of equations:

p = bqq − r1p− r1 = b1q − r2

...

p− rq = bqq − rq+1

where 0 ≤ ri < q for all i. Moreover, ri 6= rj whenever 1 ≤ i < j ≤ q.

Page 9: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 9

Proof. First, by Proposition 1.6, bq =⌈pq

⌉= t1. Now, for each 0 ≤ i ≤

q + 1, there exists a unique ri satisfying

(2) ip = q

⌈ip

q

⌉− ri

with 0 ≤ ri < q. Therefore, by definition, ip = qti − ri. Since t1 = bqwe get p = qt1 − r1 = qbq − r1. Now, for 1 ≤ j ≤ q we have

p = (j + 1)p− jp = (qtj+1 − rj+1)− (qtj − rj),

and rearranging this gives p− rj = q(tj+1 − tj)− rj+1. Since j ≥ 1,weknow tj+1 − tj = bj and so

p− rj = qbj − rj+1.

Finally, from this construction, we deduce that ri = −ip (mod q).Since gcd(p, q) = 1, we conclude ri 6= rj for 1 ≤ i < j ≤ q. �

The secondary sequence r = (r1, . . . , rq), constructed in Lemma 1.7,is uniquely determined by p and q and will play a role in our investiga-tion of p

q-representations; we call this sequence the p

q-cobranch sequence.

Corollary 1.8. Let b = (b1, . . . , bq) be the pq-branch sequence and r =

(r1, . . . , rq) be the corresponding cobranch sequence.

(1) For each i, ri + kq < p for all k < bi.(2) For each i, ri + qbi ≥ p.(3) For each i, ri = −ip (mod q).

(4) If v = jp for some j, then⌈vq

⌉= v+ri

qwhere i = j (mod q).

Proof. According to the previous proof we know that

p− ri = qbi − ri+1 > qbi − q

since ri+1 < q. Now, since qbi− q = q(bi−1) we have p > q(bi−1) + ri,which implies p > qk + ri for k < bi.

For part (2), we note that 0 ≤ ri+1 and so p − ri = qbi − ri+1 ≤ qbiand the result follows.

Part (3) is immediate from the last remark in the proof of Lemma1.7. Finally, the previous lemma implies rq = 0 and so ri = rj wheneveri = j (mod q); thus, part (4) follows from Equation (2). �

Corollary 1.9. Let w ∈ N and a ∈ {1, . . . , w− 1} with gcd(a, w) = 1.Then, for all n ∈ N, if c = (c1, ..., cw) is the wn+a

w-branch sequence,

then the w(n+1)+aw

-branch sequence is (c1 + 1, . . . , cw + 1).

Page 10: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

10 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Proof. We know that wn+ a− ri = wci − ri+1 for all i, and adding wto both sides yields w(n + 1) + a − ri = w(ci + 1) − ri+1. The resultfollows by Lemma 1.7. �

Next, we define two functions on finite sequences. For any finitesequence s given by s = (s1, s2, ..., st−2, st−1, st), we let

(3)τ(s) = (s1, s2, ..., st−2, st, st−1), and

ρ(s) = (s2, s3, ..., st−1, st, s1).

Thus, τ swaps the last two entries of s and ρ rotates the first entry ofs to the last. In the special case where s = (s1), we let τ(s) = s andρ(s) = s. We write ρk(s) to denote k successive applications of ρ.

Proposition 1.10. If b is the pq-branch sequence, then

τ(b) = ρd(b)

where d is the smallest positive integer satisfying dp = 1 (mod q).

Proof. When q = 1, the statement is clear by convention, so we mayassume q > 1 and thus p

q6∈ N. Let b = (b1, ..., bq−1, bq). We must show

that bi = bi+d (mod q) for all 1 ≤ i ≤ q − 2, bq = bd−1 and bq−1 = bd.Recall that bi+d = bi+d (mod q).

First, let i be fixed with 1 ≤ i ≤ q − 2. Then, since we know thatdp = 1 (mod q), it follows that dp = 1 + qm for some m ∈ Z. Thus,

bi+d =

⌈(i+ d+ 1)p

q

⌉−⌈

(i+ d)p

q

⌉=

⌈(i+ 1)p

q+dp

q

⌉−⌈ip

q+dp

q

⌉=

⌈(i+ 1)p

q+

1

q+mq

q

⌉−⌈ip

q+

1

q+mq

q

⌉=

⌈(i+ 1)p

q+

1

q+m

⌉−⌈ip

q+

1

q+m

⌉=

⌈(i+ 1)p

q+

1

q

⌉−⌈ip

q+

1

q

⌉.

Now, suppose that⌈(i+1)p

q+ 1

q

⌉6=⌈(i+1)p

q

⌉and let z =

⌈(i+1)p

q

⌉. This

assumption implies that (i+1)p = qz−u1 and (i+1)p+1 = q(z+1)−u2where 0 ≤ u1, u2 < q. Subtracting these two equations gives 1 =q+u1−u2, which means u2 = u1 +q−1. However, since u2 ≤ q−1, wesee that u1 = 0, implying (i + 1)p = qz. Since gcd(p, q) = 1, we musthave p = z and q = i + 1. Thus i = q − 1, which is a contradiction;

Page 11: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 11

hence,⌈(i+1)p

q+ 1

q

⌉=⌈(i+1)p

q

⌉. A similar argument shows that since

i 6= q, we have⌈ipq

+ 1q

⌉=⌈ipq

⌉. Thus, we see that

bi+d =

⌈(i+ 1)p

q

⌉−⌈ip

q

⌉= bi,

as required.Next, we have

bd =

⌈(d+ 1)p

q

⌉−⌈dp

q

⌉=

⌈1 + qm+ p

q

⌉−⌈

1 + qm

q

⌉=

⌈p+ 1

q

⌉−⌈

1

q

⌉.

Now, pq6∈ N so p = q

⌈pq

⌉− r where 1 ≤ r ≤ q − 1. Hence p + 1 =

q⌈pq

⌉−(r−1) where 0 ≤ r−1 ≤ q−1 and thus

⌈pq

⌉=⌈p+1q

⌉. Moreover⌈

1q

⌉= 1; so bd =

⌈pq

⌉− 1 =

⌊pq

⌋= bq−1 by Proposition 1.6.

Similarly, we check that

bd−1 =

⌈dp

q

⌉−⌈

(d− 1)p

q

⌉=

⌈1

q

⌉−⌈−pq

⌉=

⌈1

q

⌉+

⌊p

q

⌋.

Then⌈1q

⌉= 1, and since p

q6∈ N we get bd−1 = 1 +

⌊pq

⌋=⌈pq

⌉= bq. �

We call the property described in Proposition 1.10 the rotate-swapproperty. Euclidean strings, defined in [8], satisfy a similar property.

Proposition 1.11. The pq-branch sequence b is the unique length q

sequence, with entries adding to p, satisfying the rotate-swap property.

Proof. Proposition 1.10 implies that ρ−1(τ(b)) is a Euclidean string,and Euclidean strings are shown to be unique in Lemma 1 of [8]. �

We use this uniqueness to construct pq-branch sequences using a com-

binatorial and number theoretic object known as the Stern-Brocot tree,which we will describe below. The following result appears to be anal-ogous to a result proved about binary Euclidean strings (using only thedigits 0 and 1) (see [8]) as well as a result about Christoffel words (see[6]).

We define the mediant of two fractions ab

and cd

to be the fractionab⊕ c

d= a+c

b+d; this is often referred to as Farey arithmetic. We follow

[11] and repeatedly apply the mediant operation to construct the Stern-Brocot tree recursively. We start with the sequence of pseudo-fractions

Page 12: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

12 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

f0 = (01, 10). Then, for i > 0, we let fi be the sequence obtained from

fi−1 by inserting the mediant of two consecutive entries of fi−1 betweenthose entries (we call these mediant sequences). For example, the firstfew mediant sequences are

f0 =

(0

1,1

0

)f1 =

(0

1,1

1,1

0

)f2 =

(0

1,1

2,1

1,2

1,1

0

)f3 =

(0

1,1

3,1

2,2

3,1

1,3

2,2

1,3

1,1

0

).

For each new mediant, mn

, introduced in the sequence fi, we call theentries before and after m

nin fi the Farey ancestors of m

n. It is well

known that if ab

and cd

are the Farey ancestors of mn

, then an−bm = ±1and cn− bm = ±1 and have different parity.

Using the mediant sequences, we define the Stern-Brocot tree asfollows (see also A007305 and A047679 in [1]). For each i ≥ 1, we letthe set of vertices at level i be the mediants appearing for the firsttime in the sequence fi. Additionally, for each fraction a

bat level i ≥ 2,

there is an edge to its unique Farey ancestor in level i− 1; we call thisancestor simply the parent of a

band refer to the other Farey ancestor

as the Farey parent. In Figure 1, we have included a picture of theStern-Brocot tree up to level five. For instance, we see that 4

5appears

for the first time in f5, has an edge to its parent 34

in level four, and

has Farey parent equal to 11.

As mentioned above, branch sequences are related to Christoffelwords and Euclidean strings, which can both be generated using theStern-Brocot tree. Thus, we expect the same to be true of branch se-quences. To describe this connection, we note that if s = (s1, . . . , sk)and u = (u1, . . . , ul) are two sequences then we write su to mean theconcatenation of the two sequences, i.e. su = (s1, . . . , sk, u1, . . . , ul).

Lemma 1.12. Let s be any finite sequence. If s = s1s2 where the lengthof s2 is greater than 1, we have τ(s) = s1τ(s2).

Proof. This is clear as τ only interchanges the last two elements. �

Lemma 1.13. Let rs> 1 be a reduced fraction with s ≥ 2, and assume

p1

is a Farey ancestor of rs

with p1> r

s. Then the r

s-branch sequence is

given by c = (p, p, ..., p, p− 1, p).

Page 13: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 13

15

27

38

37

47

58

57

45

54

75

85

74

73

83

72

51

14

25

35

34

43

53

52

41

13

23

32

31

12

21

11

01

10

Figure 1. The Stern-Brocot tree.

Proof. The assumptions of the lemma imply ps−r = 1. Thus r = ps−1,and the result follows by applying Lemma 1.7 to r

s= ps−1

s. �

Theorem 1.14. Suppose that vw

is a fraction satisfying v > w ≥ 2 andgcd(v, w) = 1. Let p

q> r

sbe the Farey ancestors of v

w. If b is the p

q-

branch sequence and c is the rs-branch sequence, the v

w-branch sequence

is τ(c)b.

Proof. By assumption we know v = p + r and w = q + s; moreover,properties of the Stern-Brocot tree guarantee ps− rq = 1.

Now, assume the desired property holds for all ancestors of vw

, inparticular for p

qand r

s. Since ps− qr = 1, we conclude ps = 1 (mod q)

and (−q)r = 1 (mod s). So (p+ r)s− (q + s)r = ps+ rs− qr − rs =pr − qs = 1, which implies (p + r)s = 1 (mod q + s). Now, let d bethe v

w-branch sequence. We know ρs(d) = τ(d) since sv = 1 (mod w).

By Proposition 1.11, d is the unique length w sequence whose entriessum to v with this property. Let a be the sequence a = τ(c)b. If boths = 1 and q = 1, then a = d according to the convention after (3).Otherwise q 6= s.

Case 1: Assume q > s ≥ 1. This implies that q ≥ 2, rs

is aFarey ancestor of p

q, and p

qis the parent of v

w. By induction b =

τ(c)b′ where b′ is the sequence associated with the other Fareyancestor of p

q. By Proposition 1.10, we know that τ(b) = ρs(b).

Notice that τ(a) = τ(τ(c)b) = τ(c)τ(b) by Lemma 1.12. Next,τ(c)τ(b) = τ(c)ρs(b) = τ(c)ρs(τ(c)b′) = τ(c)b′τ(c) wherethe last equality follows since the τ(c) has length s. Finally,τ(c)b′τ(c) = bτ(c) = ρs(τ(c)b) = ρs(a), and so τ(a) = ρs(a).

Case 2: Assume s > q ≥ 1.

Page 14: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

14 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Case A: Assume q = 1. Then p1

is a Farey ancestor of rs.

By Lemma 1.13, we know that c = (p, p, ..., p, p − 1, p),which implies a = τ(c)b = (p, p, ..., p, p−1, p). In this cases = w − 1 and so ρs(a) = ρw−1(a) = (p, p, ..., p, p− 1), andτ(a) = (p, p, ..., p, p− 1). Hence ρs(a) = τ(a).

Case B: Assume q > 1. This implies that s > q ≥ 2,pq

is a Farey ancestor of rs, and r

sis the parent of v

w.

By induction we know that c = τ(c′)b where c′ is thesequence associated with the other Farey ancestor of r

s.

By Proposition 1.10 we know τ(c) = ρ−q(c) = ρs−q(c)since s > q and s − q = −q (mod s). Now, we noticethat τ(a) = τ(c)τ(b) by Lemma 1.12. Then we haveτ(c)τ(b) = ρs−q(c)τ(b) = ρs−q(τ(c′)b)τ(b) = bτ(c′)τ(b)since the length of τ(c′) is s − q. Finally bτ(c′)τ(b) =bτ(τ(c′)b) = bτ(c) = ρs(τ(c)b) = ρs(a) using Lemma1.12 and the fact that the length of τ(c) is s.

In each case, we see that τ(a) = ρs(a). Also, a has length w with entriesadding to v by construction. As noted, d is the unique sequence withthese properties, and therefore d = a = τ(c)b. �

Theorem 1.14 provides a method of recursively generating branchsequences for each rational number greater than 1 using the right halfof the Stern-Brocot tree. First, by Proposition 1.6, we see that eachinteger b, which is along the right side of the right half of the Stern-Brocot tree, has b

1-branch sequence b = (b). Now, we construct the

branch sequence for a fraction by concatenating the branch sequencesof its Farey ancestors after swapping the last two entries of the left(smallest) Farey ancestor. In Figure 2, we show the first five levelsof the branch tree and the corresponding branch sequences. In thisexample, we compare the tree to the Stern-Brocot tree in Figure 1to see that the 8

5-branch sequence is (2, 1, 2, 1, 2); this is obtained by

swapping the (last) two entries of the 32-branch sequence (1, 2) and

concatenating with the 53-branch sequence (2, 1, 2).

We will use branch sequences to describe a combinatorial model forpq-representations of natural numbers. The previous connection to the

Stern-Brocot tree suggests that there may be an intricate relation be-tween the v

w-representations, p

q-representations, and r

s-representations

of natural numbers when pq

and rs

are the Farey ancestors of vw

. This

seems to be the first suggestion that the Stern-Brocot tree is connectedto rational base arithmetic.

Page 15: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 15

(1, 1, 1, 2) (1, 2, 1, 1, 2) (2, 1, 2, 1, 2) (2, 2, 1, 2) (2, 2, 3) (3, 2, 3) (3, 4) (5)

(1, 1, 2) (2, 1, 2) (2, 3) (4)

(1, 2) (3)

(2)

(1)

Figure 2. The branch sequence tree.

2. A combinatorial model for pq-representations

We again fix two natural numbers p and q satisfying p > q ≥ 1 andgcd(p, q) = 1. For any natural number n ∈ N, we say n is of q-type s(or simply type s since q is fixed) if s is the unique integer in {1, . . . , q}satisfying n = s (mod q). Finally, we let b = (b1, . . . , bq) be the p

q-

branch sequence and r = (r1, . . . , rq) be the corresponding cobranchsequence.

Let g0 : N → N given by g0(n) = p⌈nq

⌉be the function defined in

Section 1. For any k ∈ N, we define gk : N→ N by gk(x) = g0(x) + kp.

Furthermore, we define u : N → N by u(x) = p⌊qxp2

⌋. We call each

function gk a down-edge map and u the up-edge map.

Using the maps above, we define Tp/q to be an infinite, labeled graphas follows. Let the vertex set be the multiples of p. For each vertex vof type i, we get edges of the form v → gk(v) (when gk(v) 6= 0) for allk < bi, and we label each such edge by ri + kq. This construction isbasically the one given in [2] (and used in [9]), but that constructiondoes not make use of the branch sequence.

As can be seen in [2], [9] and below, Tp/q is a tree and each function gkmaps a vertex to one of its children. The following proposition explainsthat u maps each vertex to its parent.

Proposition 2.1. Suppose v = pn where n ∈ N and v is of type i.Then u(gk(v)) = v for all k < bi.

Page 16: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

16 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Proof. Let v = pn be of type i and k < bi. Then u(gk(v)) is given by

p

⌊q

p

((pdvq e+ kp)

p

)⌋= p

⌊q

p

(⌈v

q

⌉+ k

)⌋= p

⌊q

p

(v + ri

q+ k

)⌋according to Corollary 1.8. Also

p

⌊q

p

(v + riq

+ k

)⌋= p

⌊v

p+ri + qk

p

⌋= p

⌊pn

p+ri + qk

p

⌋.

Consequently

u(gk(v)) = p

⌊pn

p+ri + qk

p

⌋= p

(n+

⌊ri + qk

p

⌋)= pn = v.

where the third equality follows since ri + qk < p by Corollary 1.8. �

Notice that u is only a partial inverse for gk as the previous result istype-dependent (and only applies for multiples of p).

Lemma 2.2. Let v be a multiple of p. Assume that v is of type i andk < bi. If v = (0, v1, ..., vn) p

q, then gk(v) = (0, ri + kq, v1, ..., vn) p

q.

Proof. Since v is of type i, Corollary 1.8 implies that

g0(v) =p

q(v + ri) = (0, ri, v1, ..., vn) p

q.

The second equality follows from the fact that multiplication of a mul-tiple of q by p

qshifts the digits. Then

gk(v) = g0(v) + kp = (0, ri, v1, ..., vn) pq

+ kp = (0, ri + kq, v1, ..., vn) pq,

where the last equality follows from Theorem 1.1. By Corollary 1.8,ri + kq < p, and so we have the valid p

q-representation of gk(v). �

We will use Lemma 2.2 to show that Tp/q describes the pq-representations

of the multiples of p. Before we explain this, we prove the following

theorem, which allows us to prove that Tp/q is a tree and that it canbe constructed in a purely combinatorial manner.

Theorem 2.3. Let v be a multiple of p that is of type i. Then

gbi−1(v) + p = g0(v + p).

Proof. Since v is a multiple of p, we know v = (0, v1, ..., vn) pq. Let j be

the minimal index with vj < p − q. Since v is type i, v + p is of typei+ 1. Notice that

v + p = (0, v1 + (p− q), v2 + (p− q), ..., vj + q, vj+1, ..., vn) pq

Page 17: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 17

0

3

6

9 12

15 2118

24 3027 33

36 39 42 45 48 51

54 57 60 63 66 69 72 75 78

2

1

0 2

1 0 2

1 0 2 1

0 2 1 0 2 1

0 2 1 0 2 1 0 2 1

Figure 3. The 32-representation tree.

by Theorem 1.1. By Lemma 2.2

g0(v + p) = (0, ri+1, v1 + (p− q), v2 + (p− q), ..., vj + q, vj+1, ..., vn) pq

and

gbi−1(v) + p = (0, ri + (bi − 1)q, v1, v2, ..., vn) pq

+ p.

Due to Corollary 1.8, we know ri + biq ≥ p; thus by Theorem 1.1

gbi−1(v)+p = (0, ri+(bi−1)q−(p−q), v1+(p−q), v2+(p−q), ..., vj+q, vj+1, ..., vn) pq.

By Lemma 1.7, ri+1 = ri + qbi− p. Hence g0(v+ p) = gbi−1(v) + p. �

Theorem 2.3 implies that every multiple of p has exactly one incom-

ing edge; therefore, Tp/q is an infinite, labeled, rooted tree with root 0.

We call Tp/q the pq-representation tree. See Figure 3 for a picture of the

32-representation tree up to 78.

Since Tp/q is a rooted tree, there is a unique path from each vertex(i.e. multiple of p) to 0. Given a multiple of p, say v, we let ev =(e1, . . . , en) be the sequence of edge labels of the path from v to 0 in

Tp/q. We call ev the edge sequence for v. The edge sequences encodethe p

q-representations for multiples of p.

Page 18: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

18 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Theorem 2.4. Let v be a multiple of p with ev = (e1, . . . , en) thecorresponding edge sequence. Then the p

q-representation of v is

v = (0, e1, . . . , en) pq.

Proof. This follows by induction on path length using Lemma 2.2. �

Corollary 2.5. Let m ∈ N. Then the pq-representation of m is

m = (u, e1, . . . , en) pq,

where u is the unique integer 0 ≤ u < p satisfying m = ip + u and(e1, . . . , en) is the edge sequence for ip.

For example, we use Figure 3 to see that since 65 = 63 + 2, we know65 = (2, 0, 1, 0, 0, 2, 1, 2) 3

2, which is shown by the red, dashed lines.

Corollary 2.6. Let a ∈ N with a ≥ 3 and m ∈ N with m ≥ a(a− 1).The a

a−1-representation of m is

m = (m0,m1, . . . ,mi, 1, 2, 3, . . . , a− 2, a− 1) aa−1.

Proof. According to the construction of the branch tree (see Figure 2),we have that the a

a−1 -branch sequence is (1, 1, . . . , 1, 2) and so the aa−1 -

tree begins with a − 1 single edges labeled by the cobranch sequence(a− 1, a− 2, . . . , 2, 1). �

Corollary 2.7. For all n ∈ N, n is a multiple of q if and only if

n = (e1, . . . , en) pq

where (e1, . . . , en) is some edge sequence in Tp/q.

Proof. Let n = qk for some k ∈ N with n = (n0, n1, . . . , nm) pq. Now,

pk = pqn = (0, n0, n1, . . . , nm) p

q. Since pk is a vertex of Tp/q, the edge se-

quence of the path from pk to 0 is (n0, n1, . . . , nm). The other directionis similar. �

For instance, (2, 2, 0, 2, 1, 2) is an edge sequence in T3/2 (see Figure3), and so (2, 2, 0, 2, 1, 2) 3

2is the 3

2-representation of a number that is

divisible by 2 (it is equal to 32).

If qn = (n0, n1, . . . , nk) pq, then n =

∑ki=0

ni

q

(pq

)i; the natural number

representations of the latter type are precisely those considered in [2],[9], and [17]. Thus, those representations, called the 1

qpq-representations,

correspond to the pq-representations of the multiples of q, and Corollary

2.7 explains why the tree Tp/q is relevant for both types of representa-tions.

In [2], [9], and above, the construction of the tree Tp/q relies heavilyon the down-edge maps, which are only partially defined maps. It turns

Page 19: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 19

out that these trees can be constructed purely using the combinatorialdata in the branch sequence. As noted a similar construction can befound in [16].

We define Tp/q be the infinite, labeled, rooted tree with vertex setthe multiples of p, root 0, and edges constructed in stages as follows.

Stage 1: Connect 0 to each vertex in {p, 2p, . . . , (bq − 1)p}.General stage: Let v be the minimal vertex with no outgoing

edges. If v is of type s, then connect v to the smallest bs verticesthat, at this stage, have no incoming edges.

Note that Tp/q is a rooted tree as each vertex (except for 0) has exactlyone incoming edge. Each vertex of type s has exactly bs children (andhence bs outgoing edges). For v = ip, we label the incoming edge to vby iq (mod p).

For instance, Figure 3 also shows the tree T3/2. The 32-branch se-

quence is (1, 2) so we first connect 0 to the b2 − 1 = 2 − 1 = 1 vertexin {3}. We then traverse the newly added vertices alternating betweenadding a single branch and a double branch. Each edge is labeled bythe successive multiples of 2 mod 3. It is not a coincidence that the

trees T3/2 and T3/2 are the same.

Theorem 2.8. The two infinite, labeled, rooted trees Tp/q and Tp/q areidentical.

Proof. By construction, both trees have vertex set equal to the multi-ples of p and both trees have 0 as the root. Moreover, we see that 0has edges to the set of vertices {p, 2p, . . . , (bq − 1)p} in both cases. Bydefinition, if v is of type s, then gk+1(v) = gk(v) + p when k < bs − 1and by Theorem 2.3 gbs−1(v) + p = g0(v + p). The result then followsby induction on the multiples of p; in particular, if we suppose the twotrees coincide up to the vertex ip, then the previous two facts implythat the trees also agree on the vertex ip+ p = (i+ 1)p. Finally, notethat the first edge label (on the edge connecting 0 to p) in both trees isq = rq + q, since rq = 0. Then, by Theorem 2.3 and Corollary 1.8, each

successive edge of Tp/q is labeled by the next multiple of q (mod p),which matches Tp/q. �

In practice, constructing Tp/q is a simple process and both vertexand edge labeling can be done after construction. After the first stage(which is special) we periodically cycle through the branch sequence:when we are at entry b in the branch sequence, we populate the oldestconstructed vertex that has no outgoing edges with b outgoing edges tob new vertices. Finally, we label the edges by multiples of q mod p andthe vertices by the multiples of p in the order they were added to the

Page 20: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

20 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

tree. For instance, Figure 4 show the first seven stages of constructingT5/3 whose branch sequence is (2, 1, 2). In the last image, we add thevertex labels (i.e. the multiples of 5) and the edge labels, which areobtained by cycling through 3, 1, 4, 2, 0 (i.e. the multiples of 3 mod 5).A slightly more complicated example is pictured in Figure 5 where weuse the 9

4-branch sequence (2, 2, 2, 3).

Proposition 2.9. Let n = (n0, n1, ..., nk) pq. Then n0 = n (mod p)

and for i > 0, ni = q(

ui−1(v)p

)(mod p) where v = p

⌊np

⌋and u is the

up-edge map.

Proof. By Proposition 2.1 and the construction of Tp/q, u(v) is theunique vertex with an edge to v. Corollary 2.5 then implies that ni

is the edge label of the incoming edge of w = ui−1(v). Finally, the

construction of Tp/q shows this edge label is q(

wp

)(mod p). �

We finish this section by providing a formula that counts the num-ber of nodes at any level in Tp/q; for examples of these sequences seeA073941, A072493 and A120160 in [1]; this result answers a questionfound in A073941.

Theorem 2.10. The number of vertices of distance n from the root inTp/q is given by an where a0 = 1 and for n ≥ 1

an =

⌈(p− q)q

·n−1∑i=0

ai

⌉.

Proof. Let (k1, k2, k3, . . .) be the sequence of knockout carries as definedin Proposition 1.5. Then, by that proposition and the construction of

Tp/q, kj is the the minimal vertex of distance j from 0. Therefore, for

n ≥ 1 we know that kn = p∑n−1

i=0 ai, and this implies

an =kn+1 − kn

p.

Recall kn+1 = g0(kn) = p⌈knq

⌉and assume that kn is of type i. Then

an =

⌈knq

⌉− kn

p=

kn + riq

− knp

=kn(p− q)

pq+

riq,

and so

an =(p− q)

∑n−1i=0 ai

q+riq.

Finally, since 0 ≤ ri < q, we conclude an =⌈(p−q)

q·∑n−1

i=0 ai

⌉. �

Page 21: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 21

Stage 1 Stage 2 - branch twice

0

5

10 15

20 3025

0

5

10 15

20 3025

Stage 3 - branch once Stage 4 - branch twice

0

5

10 15

20 3025

0

5

10 15

20 3025

Stage 5 - branch twice Stage 6 - branch once

0

5

10 15

20 3025

35 4045 5550

3

1 4

2 0 3

1 4 2 0 3

0

5

10 15

20 3025

35 4045 5550

3

1 4

2 0 3

1 4 2 0 3

Stage 7 - branch twice Populate vertices and edges

0

5

10 15

20 3025

35 4540 5550

3

1 4

2 0 3

1 4 2 0 3

0

5

10 15

20 3025

35 4540 5550

3

1 4

2 0 3

1 4 2 0 3

Figure 4. Seven stages of generating T5/3 with branchsequence (2, 1, 2) labeled accordingly.

Page 22: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

22 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

• • • • • • • • • • • • • • • • • • • •

• • • • • • • • •

• • • •

• •

Figure 5. The tree T9/4 generated by the 94-branch se-

quence (2, 2, 2, 3). The vertices should be labeled withthe multiples of 9, top to bottom and left to right. Sim-ilarly, the edges should be labeled by cycling through4, 8, 3, 7, 2, 6, 1, 5, 0.

We add to Proposition 1.5 by combining Theorem 2.10 and Propo-sition 1.5 to obtain an alternate formula for the number of positiveintegers whose p

q-representations have length n.

Corollary 2.11. For n ≥ 1, the number of positive integers with pq-

representations of length n, denoted cn, is given by cn = pan where(a1, a2, a3, . . .) is the sequence described in the previous theorem.

To demonstrate the last two results, we refer to Figure 5, whichshows the tree T9/4. Using Theorem 2.10, we can compute that levels0-5 contain 1, 2, 4, 9, 20 and 45 vertices respectively. Therefore, thereare 180 = 9 · 20 natural numbers whose 9

4-representations are length 4.

3. Combinatorics of pq-representations

The results from the previous sections allow us to partially generalizethe results of [4] and [5] to p

q-representations. We proceed to investigate

some of the combinatorics associated with pq-representations. As in the

previous sections, we fix p, q ∈ N, with p > q ≥ 1 and gcd(p, q) = 1.If n = (n0, n1, . . . , nk) p

qand m = (m0,m1, . . . ,ml) p

qare both natural

numbers, we say n � pqm when ni ≤ mi for all i (recall that ni = 0

for i > k and mi = 0 for i > l), and we say m dominates n in base-pq.

Page 23: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 23

Since pq-representations are unique, � p

qis a partial order on N, which

we call the pq-dominance order (see [19] for more information about

partial orders). When q = 1, dominance order is fully understood bythe results in [5]; the poset is a graded lattice with rank function givenby the sum-of-digits function. Unfortunately, when q 6= 1, the posetsatisfies none of these properties (see Figure 6). Nonetheless, there isa connection to the system of base-p

qarithmetic described in Section 1.

Theorem 3.1. For n,m ∈ N, n� pqn+m if and only if

∑i≥0

εpq,n,m

i = 0.

Proof. Let n = (n0, n1, . . . , nk) pq

and m = (m0,m1, . . . ,ml) pq

both be

natural numbers. First, we assume that the sum of carries is nonzeroand that i is the minimal index with εi 6= 0. By definition,

εi =

⌊ni +mi + qεi−1

p

⌋.

Since εi−1 = 0, we have

εi =

⌊ni +mi

p

⌋<

⌊2p

p

⌋= 2.

Therefore εi = 1. Since mi < p, following Equation (1), we know

(n+m)i = ni +mi − p < ni + p− p = ni.

Hence, (n+m)i < ni and so n 6� pqn+m. We conclude that n� p

qn+m

implies∑

i≥0 εi = 0.For the other direction, we assume

∑i≥0 εi = 0, which this means

εi = 0 for all i. Then, for each i, we see

(n+m)i = ni +mi + q(0)− p(0) = ni +mi.

However, mi ≥ 0 so that (n+m)i ≥ ni. By definition, n� pqn+m. �

In order to generalize the results in [4], we first need to introducethe following important sequence generated using the tree Tp/q and theassociated down-edge map g0. Let (h1, h2, h3 . . .) be the sequence givenby h1 = 1 and

hn =

{hi + 1 if np = g0(ip) for some i,

1 otherwise.

We can construct this sequence using an alternate labeling of the treeTp/q as follows. We label the root, 0, by 0. Next, if a vertex has beenlabeled m, we label the minimal child (i.e. the first created duringconstruction of Tp/q) by m + 1 and label the other children by 1. The

Page 24: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

24 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

0

1 369 15 1824 27 364245

2 4710 16 1925 28 374346

5811 17 2026 29 384447

12 2130 3948

13 2231 4049

14 2332 4150

33

34

35

Figure 6. The Hasse diagram of 32-dominance order

truncated at 50 created using Sage ([20]).

entry hi corresponds to the label attached to the vertex ip. See Figure7 for this labeling of T3/2 (compare to Figure 3). A closed form for thissequence comes from the sum-of-digits function.

Theorem 3.2. The sequence (h1, h2, h3, . . .) defined recursively aboveis given by

hi =1

p− q

(p+ sum p

q((i− 1)p)− sum p

q(ip)

).

Proof. Let (y1, y2, y3, . . .) be the sequence given by

yi =1

p− q

(p+ sum p

q((i− 1)p)− sum p

q(ip)

).

Without loss of generality, we assume that ip is of type s + 1, whichmeans (i−1)p is of type s. Now, let ip = (0, e1, . . . , ek) p

qand (i−1)p =

(0, e′1, . . . , e′t) p

q. According to Theorem 2.3 and Lemma 2.2,

g0(ip)− p = gbs−1(ip− p) = (0, rs + (bs − 1)q, e′1, . . . , e′t) p

q

Page 25: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 25

0

1

2

3 1

4 12

5 13 2

6 1 4 2 1 3

7 1 2 5 1 3 2 1 4

Figure 7. The 32-representation tree with alternate

labeling. The corresponding sequence (h1, h2, . . .) is(1, 2, 3, 1, 4, 2, 1, 5, 3, 1, 2, 6, 1, 4, 2, 1, 3, 7, 1, 2, 5, 1, 3, 2, 1, 4, . . .); seeA087088 in [1].

and g0(ip) = (0, rs+1, e1, . . . , ek) pq. Hence

sum pq(g0(ip)− p)− sum p

q(g0(ip)) = sum p

q(gbs−1(ip− p))− sum p

q(g0(ip))

=∑i≥0

e′i + (bs − 1)q + rs −∑i≥0

ei − rs+1

=∑i≥0

e′i −∑i≥0

ei + bsq − q + rs − rs+1

= sum pq((i− 1)p)− sum p

q(ip) + p− q,

where the last equality follows from Lemma 1.7. Thus, if np = g0(ip),then

yn =1

p− q

(p+ sum p

q(np− p)− sum p

q(n))

=1

p− q

(p+ sum p

q((i− 1)p)− sum p

q(ip) + p− q

)= yi +

p− qp− q

= yi + 1.

Next, if np 6= g0(ip) for any i, then u(np) = u((n − 1)p) where u isthe up-edge map, i.e. np and (n − 1)p have the same parent in Tp/q.Theorem 2.4 implies that we must have np = (0, e1, e2, . . . , ek) p

qand

(n− 1)p = (0, d1, e2, . . . , ek) pq; moreover, e1 = d1 + q by construction of

Page 26: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

26 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

Tp/q. Therefore,

yn =1

p− q

(p+ sum p

q((n− 1)p)− sum p

q(n))

=1

p− q(p+ d1 − e1) = 1.

Since (y1, y2, y3, . . .) satisfies the same recurrence as (h1, h2, h3, . . .) andy1 = 1 = h1, the two sequences must be the same. �

In the case where q = 1, this sequence is sometimes referred to as aruler sequence, and in this case, hn gives the largest power of p dividingpn. See A001511, A051064, or A115362 in [1] for examples. We usethis sequence to construct another sequence, which corresponds to thep-adic valuation when q = 1. Let (v1, v2, v3, . . .) be given by

vi =

{h i

pif i is a multiple of p

0 otherwise.

For instance, the corresponding sequence for the 32-representations ac-

cording to Figure 7 is

(0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 1, 0, 0, 4, 0, 0, 2, 0, 0, 1, 0, 0, 5, 0, 0, 3, . . .),

and the sequence for 21-representations is

(0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, . . .),

which is the 2-adic valuation (see in A007814 [1]). The sequence(v1, v2, v3, . . .) leads us to a result similar to Kummer’s Theorem (see[4]) for p

q-representations.

For any sequence of nonzero natural numbers, C, we define the C-factorial by

(m!)C =

{CmCm−1 · · ·C1 when m 6= 0

1 when m = 0.

We use the C-factorial to construct generalized binomial coefficientsassociated to C, called the C-nomial coefficients, which are given by(

m

n

)C

=

{(m!)C

(n!)C((m−n)!)Cwhen 0 ≤ n ≤ m

0 otherwise.

The previous construction works for any sequence of nonzero integers,but the generalized binomial coefficients cannot be expected to be in-tegers (see [13]).

Page 27: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 27

With these ideas in hand, we construct one more sequence of interest

Wpq = (W1,W2,W3 . . .) by

Wn = pvn ,

where (v1, v2, v3, . . .) is defined above and described in Theorem 3.2.For example, when p

q= 3

2, we have

W32 = (1, 1, 3, 1, 1, 9, 1, 1, 27, 1, 1, 3, 1, 1, 81, 1, 1, 9, 1, 1, 3 . . .).

In place of (m!)W we use (m!) pq, and in place of

(mn

)W

we use(mn

)pq

.

We call the latter numbers the pq-binomial coefficients.

Lemma 3.3. For any n ∈ N

(n!) pq

= p1

p−q(n−sum p

q(n))

.

Proof. Let n ∈ N such that n = mp+ u with 0 ≤ u < p. By definitionwe see that

(n!) pq

=n∏

i=1

Wi = p∑

1≤ip≤n hi .

Now, ∑1≤ip≤n

hi =1

p− q∑

1≤ip≤n

(p+ sum p

q((i− 1)p)− sum p

q(ip)

).

This sum telescopes, and so

(p− q) ·∑

1≤ip≤n

hi = mp+ sum pq(0)− sum p

q(mp)

= mp+ u− u− sum pq(mp) = n− sum p

q(n).

The result follows. �

Using the pq-binomial coefficients, we obtain the following general-

ization of the main theorem in [4], which, in turn, is an analog ofKummer’s Theorem.

Theorem 3.4. Let m,n ∈ N with n ≤ m. Then the highest powerof p that divides

(mn

)pq

is the total number of carries when adding thepq-representations of n and m− n.

Proof. As(mn

)pq

=(m!) p

q

(n!) pq((m−n)!) p

q

, we apply Lemma 3.3 and simplify:(m

n

)pq

= p( 1p−q )(sum p

q(m−n)+sum p

q(n)−sum p

q(m))

.

Now the result follows by Proposition 1.4. �

Page 28: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

28 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

We pair Theorem 3.4 with Theorem 3.1 to get a characterization ofpq-dominance in terms of the p

q-binomial coefficients.

Corollary 3.5. For all n,m ∈ N with n ≤ m, we have n� pqm if and

only if(mn

)pq

6≡ 0 (mod p).

4. Future Investigations

In this final section, we mention a few future directions for study ofthe combinatorics associated with p

q-representations.

First, since rational base dominance orders are not as well-behavedas their integral base counterparts, it would be interesting to provideother characterizations of these posets, determine how the sum-of-digitsfunction (see [17]) relates to the poset, or study other combinatorialproperties as they relate to p

q-arithmetic. Every property of the base-b

dominance orders discussed in [5] would be nice to understand for theseorders. The poset does appear to have a rank function (in the mostgeneral sense of a rank function, see [19]) though it is not the sum-of-digits function. Finding a formula for the rank function would bebeneficial; moreover, simply explaining the sequence of natural num-bers only dominating zero, which we call the rank-one elements, isdesired. For instance, in the 3

2-dominance order, the rank-one elements

are

1, 3, 6, 9, 15, 18, 24, 27, 36, 42, 45, 54, 63, 69, 81, . . . .

Moreover, we would like to know if there is a combinatorial inter-pretation of

(mn

)pq

, defined in the previous section, in terms of thepq-dominance order.

In addition to further understanding of the dominance order, theremay be other interesting combinatorics associated with the tree Tp/q. Inparticular, can we use the results in Section 3 and associated sequencesto find a closed form for the sequence of knockout carries (k1, k2, k3, . . .)from Section 1?

Finally, in the case of 32-representations, the down-edge map g0 is

related to the famous Collatz conjecture. We imagine some of the dif-ficulty in understanding the 3

2-dominance order is related to the diffi-

culty of solving the Collatz conjecture. Finding an interpretation of theCollatz conjecture in terms of 3

2-representations, the 3

2-representation

tree, or the 32-dominance order would be fascinating and lead to further

interesting questions in this situation.

Page 29: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

COMBINATORICS OF RATIONAL BASE REPRESENTATIONS 29

References

[1] OEIS Foundation Inc. (2012). The On-Line Encyclopedia of Integer Sequences,http://oeis.org.

[2] Shigeki Akiyama, Christiane Frougny, and Jacques Sakarovitch. Powers of ra-tionals modulo 1 and rational base number systems. Israel J. Math., 168:53–91,2008.

[3] Shigeki Akiyama, Victor Marsault, and Jacques Sakarovitch. Auto-similarityin rational base number systems. In Combinatorics on words, volume 8079 ofLecture Notes in Comput. Sci., pages 34–45. Springer, Heidelberg, 2013.

[4] Tyler Ball, Tom Edgar, and Daniel Juda. Dominance orders, generalized bino-mial coefficients, and Kummer’s theorem. Math. Mag., 87(2):135–143, 2014.

[5] Tyler Ball and Daniel Juda. Dominance over N. Rose Hulman UndergraduateMath Journal, 14(2):Article 2, 2013.

[6] Jean Berstel, Aaron Lauve, Christophe Reutenauer, and Franco V. Saliola.Combinatorics on words, volume 27 of CRM Monograph Series. AmericanMathematical Society, Providence, RI, 2009. Christoffel words and repetitionsin words.

[7] Felix Breuer and Frederik von Heymann. Staircases in Z2. Integers, 10:A58,807–847, 2010.

[8] John Ellis, Frank Ruskey, Joe Sawada, and Jamie Simpson. Euclidean strings.Theoret. Comput. Sci., 301(1-3):321–340, 2003.

[9] Christiane Frougny and Karel Klouda. Rational base number systems for p-adic numbers. RAIRO Theor. Inform. Appl., 46(1):87–106, 2012.

[10] Christiane Frougny and Jacques Sakarovitch. Number representation and fi-nite automata. In Combinatorics, automata and number theory, volume 135 ofEncyclopedia Math. Appl., pages 34–107. Cambridge Univ. Press, Cambridge,2010.

[11] Ronald L. Graham, Donald E. Knuth, and Oren Patashnik. Concrete math-ematics. Addison-Wesley Publishing Company, Reading, MA, second edition,1994. A foundation for computer science.

[12] Donald E. Knuth. The art of computer programming. Vol. 2. Addison-Wesley,Reading, MA, 1998. Seminumerical algorithms, Third edition [of MR0286318].

[13] Donald E. Knuth and Herbert S. Wilf. The power of a prime that divides ageneralized binomial coefficient. J. Reine Angew. Math., 396:212–219, 1989.

[14] M. Lothaire. Algebraic combinatorics on words, volume 90 of Encyclopedia ofMathematics and its Applications. Cambridge University Press, Cambridge,2002. A collective work by Jean Berstel, Dominique Perrin, Patrice Seebold,Julien Cassaigne, Aldo De Luca, Steffano Varricchio, Alain Lascoux, BernardLeclerc, Jean-Yves Thibon, Veronique Bruyere, Christiane Frougny, FilippoMignosi, Antonio Restivo, Christophe Reutenauer, Dominique Foata, Guo-NiuHan, Jacques Desarmenien, Volker Diekert, Tero Harju, Juhani Karhumaki andWojciech Plandowski, With a preface by Berstel and Perrin.

[15] Victor Marsault and Jacques Sakarovitch. On sets of numbers rationally rep-resented in a rational base number system. In Algebraic informatics, volume8080 of Lecture Notes in Comput. Sci., pages 89–100. Springer, Heidelberg,2013.

[16] Victor Marsault and Jacques Sakarovitch. Rhythmic generation of infinite treesand languages. CoRR, abs/1403.5190, 2014.

Page 30: SOME COMBINATORICS OF RATIONAL BASE REPRESENTATIONSedgartj/preprints/basepqarithmetic.pdf · representations of natural numbers elementary number theory by pro-viding a simple construction

30 TOM EDGAR, HAILEY OLAFSON, AND JAMES VAN ALSTINE

[17] Johannes F. Morgenbesser, Wolfgang Steiner, and Jorg M. Thuswaldner. Pat-terns in rational base number systems. J. Fourier Anal. Appl., 19(2):225–250,2013.

[18] A. Renyi. Representations for real numbers and their ergodic properties. ActaMath. Acad. Sci. Hungar, 8:477–493, 1957.

[19] Bernd S. W. Schroder. Ordered sets. Birkhauser Boston Inc., Boston, MA,2003. An introduction.

[20] W. A. Stein et al. Sage Mathematics Software (Version 4.8). The Sage Devel-opment Team, 2012. http://www.sagemath.org.

Department of Mathematics, Pacific Lutheran University, Tacoma,WA 98447

E-mail address: [email protected]

Department of Mathematics, Pacific Lutheran University, Tacoma,WA 98447

E-mail address: [email protected]

Department of Mathematics, Pacific Lutheran University, Tacoma,WA 98447

E-mail address: [email protected]