login
Unhappy numbers which enter the cycle (4, 16, 37, 58, 89, 145, 42, 20) at 4.
0

%I #20 Feb 16 2025 08:33:15

%S 2,4,11,78,87,101,110,113,131,168,179,186,197,200,249,257,259,275,294,

%T 295,311,429,449,467,476,492,494,527,529,559,567,572,576,592,595,618,

%U 647,657,674,675,681,708,719,725,746,752,756,764,765,779,780,791,797

%N Unhappy numbers which enter the cycle (4, 16, 37, 58, 89, 145, 42, 20) at 4.

%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/UnhappyNumber.html">Unhappy Number</a>.

%e 7899 is such a number of height 6 because it enters the cycle at 4 in 6 steps: 7899 -> 275 -> 78 -> 113 -> 11 -> 2 -> 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4 -> ...

%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=4 then a:=[op(a),i] fi; od: print(op(a));

%Y Cf. A031177, A039943.

%K nonn,base,changed

%O 1,1

%A _Martin Renner_, Jul 31 2011