OFFSET
1,2
COMMENTS
Suppose that B1 and B2 are increasing sequences of positive integers, and let B be the increasing sequence of numbers in the union of B1 and B2. Every positive integer n has a unique representation given by the greedy algorithm with B1 as base, and likewise for B2 and B. For many n, the number of terms in the B-representation of n is less than the number of terms in the B1-representation, as well as the B2-representation, but not for all n, as in the example 45 = 27 + 18 (ternary) and 45 = 32 + 9 + 4 (mixed).
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..2030
Michael S. Branicky, Proof of formula
FORMULA
a(n+1) = a(n) + t, where t is the least element in B such that the largest element of B in the interval (a(n), a(n) + t) is t; see link for proof. - Michael S. Branicky, Jan 06 2022
EXAMPLE
1 = 1 (1 term);
5 = 4 + 1 (2 terms);
14 = 9 + 4 + 1 (3 terms);
46 = 32 + 9 + 4 + 1 (4 terms);
127 = 81 + 32 + 9 + 4 + 1 (5 terms).
MATHEMATICA
z = 20; zz = 100000;
b1 = Sort[Table[2^k, {k, 0, z}], Greater];
b2 = Sort[Union[Table[3^k, {k, 0, z}], Table[2*3^k, {k, 0, z}]],
Greater]; b = Sort[Union[b1, b2], Greater];
g1 = Map[{#, DeleteCases[b1 Reap[
FoldList[(Sow[Quotient[#1, #2]]; Mod[#1, #2]) &, #, b1]][[2,
1]], 0]} &, Range[zz]];
m1 = Map[Length[#[[2]]] &, g1];
g2 = Map[{#, DeleteCases[
b2 Reap[FoldList[(Sow[Quotient[#1, #2]]; Mod[#1, #2]) &, #,
b2]][[2, 1]], 0]} &, Range[zz]];
m2 = Map[Length[#[[2]]] &, g2];
g = Map[{#, DeleteCases[b Reap[FoldList[(Sow[Quotient[#1, #2]]; Mod[#1, #2]) &, #,
b]][[2, 1]], 0]} &, Range[zz]];
m = Map[Length[#[[2]]] &, g];
(* Peter J. C. Moses, Jul 05 2020 *)
Table[First[Flatten[Position[m, k]]], {k, 1, 11}]
PROG
(Python)
from itertools import count, takewhile, islice
def big_greedy(k, B, start=0):
idx = start
while idx < len(B) and B[idx] <= k: idx += 1
return B[idx - 1]
def agen(limit=10**1001):
an, idx, t = 1, 0, 2
B1 = list(takewhile(lambda x: x <= limit, (2**i for i in count(0))))
B21 = list(takewhile(lambda x: x <= limit, (3**i for i in count(0))))
B22 = list(takewhile(lambda x: x <= limit, (2*3**i for i in count(0))))
B = sorted(set(B1 + B21 + B22))
while an <= limit:
yield an
while t != big_greedy(an+t, B, start=idx):
idx, t = idx+1, B[idx+1]
an += t
print(list(islice(agen(), 28))) # Michael S. Branicky, Jan 06 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Clark Kimberling, Jul 06 2020
EXTENSIONS
a(12) and beyond from Michael S. Branicky, Jan 06 2022
STATUS
approved