A037314 Numbers whose base-3 and base-9 expansions have the same digit sum.
0, 1, 2, 9, 10, 11, 18, 19, 20, 81, 82, 83, 90, 91, 92, 99, 100, 101, 162, 163, 164, 171, 172, 173, 180, 181, 182, 729, 730, 731, 738, 739, 740, 747, 748, 749, 810, 811, 812, 819, 820, 821, 828, 829, 830, 891, 892, 893, 900, 901, 902, 909, 910, 911
Offset: 0
Programs
-
Julia
function a(n) m, r, b = n, 0, 1 while m > 0 m, q = divrem(m, 3) r += b * q b *= 9 end r end [a(n) for n in 0:53] |> println # Peter Luschny, Jan 03 2021
-
Mathematica
Table[FromDigits[RealDigits[n, 3], 9], {n, 1, 100}] (* Clark Kimberling, Aug 14 2012 *) Select[Range[0,1000],Total[IntegerDigits[#,3]]==Total[IntegerDigits[#,9]]&] (* Harvey P. Dale, Feb 17 2020 *)
-
PARI
a(n) = {my(d = digits(n, 3)); subst(Pol(d), x, 9);} \\ Michel Marcus, Apr 09 2015
Formula
G.f. f(x) = Sum_{j>=0} 9^j*x^(3^j)*(1+x^(3^j)-2*x^(2*3^j))/((1-x)*(1-x^(3^(j+1)))) satisfies f(x) = 9*(x^2+x+1)*f(x^3) + x*(1+2*x)/(1-x^3). - Robert Israel, Apr 13 2015
Extensions
Edited by N. J. A. Sloane at the suggestion of Andrew S. Plewe, Jun 08 2007
Offset changed to 0 by Clark Kimberling, Aug 14 2012
Comments