%I #17 Feb 11 2024 22:30:20
%S 38,58,73,83,116,119,161,166,191,235,253,299,307,308,325,352,357,370,
%T 375,380,468,486,489,498,523,532,537,573,611,616,648,661,679,684,697,
%U 703,730,735,753,769,796,803,830,846,849,864,894,911,929,948,967,976
%N Unhappy numbers which enter the cycle (4, 16, 37, 58, 89, 145, 42, 20) at 58.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/UnhappyNumber.html">Unhappy Number</a>.
%e 468 is such a number of height 4 because it enters the cycle at 58 in 4 steps: 468 -> 116 -> 38 -> 73 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4 -> 16 -> 37 -> 58 -> ...
%p 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:
%p a:=[]: for i from 1 while nops(a)<30 do Q:=S(i); A:=Q[nops(Q)]; if A=58 then a:=[op(a),i] fi; od: print(op(a));
%Y Cf. A031177, A039943.
%K nonn,base
%O 1,1
%A _Martin Renner_, Jul 31 2011
|