%I #24 Feb 25 2018 09:32:06
%S 0,5,7,4,4,9,5,5,6,1,6,5,2,6,6,3,5,5,4,5,5,6,3,6,3,5,6,3,2,7,2,3,6,4,
%T 5,8,2,3,7,4,6,6,4,4,7,4,5,6,4,4,6,3,5,7,5,4,6,1,4,9,3,5,8,4,4,7,2,2,
%U 8,5,5,6,2,5,6,2,9,8,3,5,5,3,3,6,1,2,8,10,0
%N a(n) is the number of steps needed to reach 1 or 89 under iteration of sum-of-squares-of-digits map.
%C By the definition, a(1) = a(89) = 0.
%H Seiichi Manyama, <a href="/A300081/b300081.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/HappyNumber.html">Happy Number</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/UnhappyNumber.html">Unhappy Number</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Happy_number">Happy number</a>
%e n| 0 1 2 3 4 5 6 7 8 9
%e -----------------------------------------------------------
%e 2| 2 -> 4 -> 16 -> 37 -> 58 -> 89.
%e 3| 3 -> 9 -> 81 -> 65 -> 61 -> 37 -> 58 -> 89.
%e 4| 4 -> 16 -> 37 -> 58 -> 89.
%e 5| 5 -> 25 -> 29 -> 85 -> 89.
%e 6| 6 -> 36 -> 45 -> 41 -> 17 -> 50 -> 25 -> 29 -> 85 -> 89.
%o (PARI) f(n) = {my(d = digits(n)); sum(k=1, #d, d[k]^2);}
%o a(n) = {my(nb = 0, fn = n); while (! ((n == 1) || (n == 89)), n = f(n); nb++); nb;} \\ _Michel Marcus_, Feb 25 2018
%Y Cf. A003621, A007770.
%K nonn,base
%O 1,2
%A _Seiichi Manyama_, Feb 24 2018
|