OFFSET
1,1
LINKS
Eric Weisstein's World of Mathematics, Unhappy Number.
EXAMPLE
568 is such a number of height 7 because it enters the cycle at 37 in 7 steps: 568 -> 125 -> 30 -> 9 -> 81 -> 65 -> 61 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4 -> 16 -> 37 -> ...
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=37 then a:=[op(a), i] fi; od: print(op(a));
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Martin Renner, Jul 31 2011
STATUS
approved