%I #52 May 28 2020 05:27:16
%S 1,3,9,13,17,23,25,27,31,35,37,39,47,51,53,59,61,65,69,71,73,75,77,79,
%T 81,85,89,91,93,101,105,107,109,111,117,137,141,143,153,155,159,161,
%U 167,169,173,177,179,181,183,185,187,191,195,197,207,209,213
%N Ternary happy numbers.
%C Numbers where the trajectory of iterated application of A006287 ends at the fixed point 1.
%H Amiram Eldar, <a href="/A239320/b239320.txt">Table of n, a(n) for n = 1..10000</a>
%H H. G. Grundmann, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL13/Grundman/grundman7.html">Semihappy Numbers</a>, J. Int. Seq. 13 (2010), 10.4.8.
%e 13 is a ternary happy number because 13=111_3 -> 1 + 1 + 1 = 3 = 10_3 -> 1 + 0 = 1.
%p isA239320 := proc(n)
%p t := A006287(n) ;
%p tloo := {} ;
%p for i from 1 do
%p if t = 1 then
%p return true;
%p end if;
%p if t in tloo then
%p return false;
%p end if;
%p tloo := tloo union {t} ;
%p t := A006287(t) ;
%p end do:
%p end proc:
%p for n from 1 to 300 do
%p if isA239320(n) then
%p printf("%d,",n) ;
%p end if;
%p end do: # _R. J. Mathar_, Jun 13 2014
%t happyQ[n_, b_] := NestWhile[Plus @@ (IntegerDigits[#, b]^2) &, n, UnsameQ, All] == 1; Select[Range[213], happyQ[#, 3] &] (* _Amiram Eldar_, May 28 2020 *)
%Y Cf. A007770, A240849.
%K nonn,base,easy
%O 1,2
%A _Jiri Klepl_, Apr 13 2014
|