[go: up one dir, main page]

login
A193571
Unhappy numbers which enter the cycle (4, 16, 37, 58, 89, 145, 42, 20) at 42.
0
42, 154, 389, 398, 415, 451, 514, 541, 839, 893, 938, 983, 1045, 1054, 1126, 1162, 1216, 1261, 1344, 1405, 1434, 1443, 1450, 1504, 1540, 1588, 1612, 1621, 1669, 1696, 1858, 1885, 1966, 2116, 2161, 2235, 2253, 2325, 2352, 2523, 2532, 2611, 3089, 3098, 3144
OFFSET
1,1
LINKS
Eric Weisstein's World of Mathematics, Unhappy Number.
EXAMPLE
389 is such a number of height 2 because it enters the cycle at 42 in 2 steps: 389 -> 154 -> 42 -> 20 -> 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> ...
MAPLE
S:=proc(n) local Q, k, N, z; Q:=[n]; for k from 1 do N:=convert(Q[k], base, 10); z:=sum(N['i']^2, 'i'=1..nops(N)); if not member(z, Q) then Q:=[op(Q), z]; else Q:=[op(Q), z]; break; fi; od; return Q; end:
a:=[]: for i from 1 while nops(a)<30 do Q:=S(i); A:=Q[nops(Q)]; if A=42 then a:=[op(a), i] fi; od: print(op(a));
CROSSREFS
Sequence in context: A189500 A350579 A075289 * A326384 A263285 A263300
KEYWORD
nonn,base
AUTHOR
Martin Renner, Jul 31 2011
STATUS
approved