login
a(0) = 0, and for n > 0, a(n) is the least multiple of n that can be added to n without carries in balanced ternary.
3

%I #10 May 01 2022 11:42:33

%S 0,2,6,6,8,30,18,21,16,18,20,55,24,26,84,90,80,51,54,57,60,63,132,46,

%T 48,75,52,54,56,87,60,62,288,165,408,70,72,74,456,78,80,246,252,516,

%U 484,270,276,658,240,441,400,153,156,159,162,165,168,171,522,649

%N a(0) = 0, and for n > 0, a(n) is the least multiple of n that can be added to n without carries in balanced ternary.

%C Two integers can be added without carries in balanced ternary if they have no equal nonzero digit at the same position.

%H Rémy Sigrist, <a href="/A353624/b353624.txt">Table of n, a(n) for n = 0..10000</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a>

%F a(n) = n * A353623(n).

%F a(3*n) = 3*a(n).

%e For n = 5:

%e - we consider the following cases:

%e k bter(k*5) carries?

%e - --------- --------

%e 1 1TT yes

%e 2 101 yes

%e 3 1TT0 yes

%e 4 1T1T yes

%e 5 10T1 yes

%e 6 1010 no

%e - so a(5) = 6*5 = 30.

%o (PARI) ok(u,v) = { while (u && v, my (uu=[0,+1,-1][1+u%3], vv=[0,+1,-1][1+v%3]); if (abs(uu+vv)>1, return (0)); u=(u-uu)/3; v=(v-vv)/3); return (1) }

%o a(n) = for (k=1, oo, if (ok(n, n*k), return (n*k)))

%Y Cf. A059095, A261892 (binary analog), A353623.

%K nonn,base

%O 0,2

%A _Rémy Sigrist_, Apr 30 2022