login
a(n) = n OR n^2 (applied to ternary expansions).
3

%I #23 Mar 29 2018 18:21:03

%S 1,5,12,16,26,42,52,71,90,100,122,147,178,206,231,259,296,342,370,401,

%T 453,484,539,591,646,701,756,784,842,930,961,1025,1095,1186,1259,1332,

%U 1369,1445,1524,1609,1691,1770,1852,1943,2070,2152,2237,2316,2401,2510

%N a(n) = n OR n^2 (applied to ternary expansions).

%C OR(a, b) = max(a, b) for ternary digits a and b. - _Sean A. Irvine_, Mar 29 2018

%H Alois P. Heinz, <a href="/A008467/b008467.txt">Table of n, a(n) for n = 1..10000</a>

%p a:= proc(n) option remember; local g, h, i, r;

%p g, h, r:= n, n^2, 0; for i from 0 while h>0 do

%p r:= r + 3^i * max(irem(g, 3, 'g'), irem(h, 3, 'h')) od; r

%p end:

%p seq(a(n), n=1..140); # _Alois P. Heinz_, Mar 29 2018

%t (* program should not be used to extend this sequence *)

%t b=3; d=9; Mb=Array[ b^(d-#)&, d ]; Map[ Plus@@(Mb*#)&, Array[ Max /@ Transpose[ {IntegerDigits[ #, b, d ], IntegerDigits[ #^2, b, d ]} ]&, 140 ] ]

%Y Cf. A007745, A008468, A008469.

%K base,nonn,easy

%O 1,2

%A _Olivier GĂ©rard_