login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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:
seq(a[i], i=1..100); # Robert Israel, Jun 24 2015
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
Sequence in context: A103828 A110740 A348555 * A206604 A084707 A193703
KEYWORD
base,nonn
AUTHOR
EXTENSIONS
Corrected by Robert Israel, Jun 24 2015
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 30 05:21 EDT 2024. Contains 374735 sequences. (Running on oeis4.)