|
|
A042938
|
|
Reverse or triple: if reverse(a(n)) > a(n), a(n+1) = reverse(a(n)), else a(n+1) = 3*a(n).
|
|
2
|
|
|
1, 3, 9, 27, 72, 216, 612, 1836, 6381, 19143, 34191, 102573, 375201, 1125603, 3065211, 9195633, 27586899, 99868572, 299605716, 617506992, 1852520976, 6790252581, 20370757743, 34775707302, 104327121906, 609121723401, 1827365170203, 3020715637281, 9062146911843
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
EXAMPLE
|
Starting with 1, the reverse is 1 and not greater than 1 so the next term is 3. The reverse of 3 is also not greater than 3 and so the next term is 9. The reverse of 9 is not greater than 9 and so the next term is 27. However, the reverse of 27 is 72 which is greater and so the next term in the sequence is 72 and so on.
|
|
MAPLE
|
reverse:= proc(n)
local L, i, m;
L:= convert(n, base, 10);
m:= nops(L);
add(L[i]*10^(m-i), i=1..m);
end proc:
a[1]:= 1:
for n from 2 to 100 do
r:= reverse(a[n-1]);
if r > a[n-1] then a[n]:= r
else a[n]:= 3*a[n-1]
fi
od:
|
|
MATHEMATICA
|
rd[n_]:=Module[{rev=FromDigits[Reverse[IntegerDigits[n]]]}, If[rev>n, rev, 3 n]]; NestList[rd, 1, 30] (* Vincenzo Librandi, Jun 24 2015 *)
NestList[If[IntegerReverse[#]>#, IntegerReverse[#], 3#]&, 1, 30] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jul 09 2018 *)
|
|
PROG
|
(PARI) lista(nn) = {print1(a=1, ", "); for (n=2, nn, r = eval(concat(Vecrev(Str(a)))); if (r > a, a = r, a *= 3); print1(a, ", "); ); } \\ Michel Marcus, Jan 31 2016
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|