OFFSET
1,2
COMMENTS
Consider numbers of the form 1, 12, 123, 1234, ..., N. Find the highest power of 3^p such that 3^p <= N. Then p = [log(N)/log(3)] and for 0 <= qi <= 2 [N/3^p] = q1 + r1 [r1/3^(p-1)] = q2 + r2 ........................ rp/3^1 = qp + rp+1 rp+1/3^0 = qp+1 0 For N = 1234, p = [log(1234)/log(3)] = 6 division quot rem 1234/3^6 = 1 505 505/3^5 = 2 19 19/3^4 = 0 19 19/3^3 = 0 19 19/3^2 = 2 1 1/3^1 = 0 1 1/3^0 = 1 0 The sequence of quotients, top down, form the entry in the table for 1234. Obviously this algorithm works for any N.
LINKS
Seiichi Manyama, Table of n, a(n) for n = 1..195
FORMULA
EXAMPLE
The 4th concatenation of the integers > 0 is 1234. base(10,3,1234) = 1200201 the 4th entry in the table.
MATHEMATICA
Table[FromDigits[IntegerDigits[FromDigits[Flatten[Table[ IntegerDigits[n], {n, i}]]], 3]], {i, 12}] (* Harvey P. Dale, May 23 2011 *)
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Cino Hilliard, Aug 29 2004
STATUS
approved