|
|
A336005
|
|
a(n) is the number of terms in the mixed binary-ternary representation of n. See Comments.
|
|
3
|
|
|
1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 3, 2, 1, 2, 1, 2, 2, 2, 2, 3, 2, 3, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 2, 3, 2, 3, 3, 3, 1, 2, 2, 2, 2, 3, 2, 3, 2, 2, 1, 2, 2, 2, 2, 3, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 2, 1, 2, 2, 2, 2, 3
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,5
|
|
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
|
|
|
EXAMPLE
|
7 = 6 + 1, so a(7) = 2.
45 = 32 + 9 + 4, so a(45) = 3.
|
|
MATHEMATICA
|
z = 20; zz = 100;
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];
m1 (* # terms in binary representation *)
m2 (* # terms in trinary representation *)
m (* # terms in mixed base representation *) (* A336005 *)
|
|
PROG
|
(Python)
from itertools import count, takewhile
N = 10**6
B1 = list(takewhile(lambda x: x[0] <= N, ((2**i, 2) for i in count(0))))
B21 = list(takewhile(lambda x: x[0] <= N, ((3**i, 3) for i in count(0))))
B22 = list(takewhile(lambda x: x[0] <= N, ((2*3**i, 3) for i in count(0))))
B = sorted(set(B1 + B21 + B22), reverse=True)
def gbt(n, B): # greedy binary-ternary representation
r = []
for t, b in B:
if t <= n:
r.append(t)
n -= t
if n == 0:
return r
def a(n): return len(gbt(n, B))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|