%I #20 Mar 23 2013 16:35:43
%S 2,3,3,23,79,2207,58775,569669,11814485,210511543,73748383237
%N Smallest number greater than 1 that is happy under bases 2 through n.
%C A happy number is a number that after iteration of sum of squares of digits eventually reaches 1 (A007770). The happy property is base-dependent. This sequence lists the smallest number that is happy in bases 2, 3, ..., n.
%C All numbers are happy in binary and base 4.
%e a(8) = 58775 because:
%e Base 2: 1110010110010111 - 1010 - 10 - 1,
%e Base 3: 2222121212 - 1011 - 10 - 1,
%e Base 4: 321121113 - 132 - 32 - 31 - 22 - 20 - 10 - 1,
%e Base 5: 3340100 - 120 - 10 - 1,
%e Base 6: 1132035 - 121 - 10 - 1,
%e Base 7: 333233 - 100 - 1,
%e Base 8: 162627 - 202 - 10 - 1,
%e Base 9 fails since the end is the 58 - 108 - 72 cycle and fails to reach 1.
%o (PARI) ssd(n,b)=my(s);while(n,s+=(n%b)^2;n\=b);s
%o happy(k,b)=my(t=ssd(k,b));k=ssd(t,b);while(t!=k&&k>1,t=ssd(t,b);k=ssd(ssd(k,b),b));k==1
%o h3(k)=while(k>8, k=ssd(k,3));k==1 || k==3
%o a(n)=if(n<4,return(n));my(k=2);while(k++, if(!h3(k),next); for(b=5,n, if(!happy(k,b), next(2)));return(k)) \\ _Charles R Greathouse IV_, Mar 22 2013
%Y Cf. A007770, A001273, A068571, A161871, A161873, A055629, A161872, A094406.
%K base,hard,nonn
%O 2,1
%A _Sergio Pimentel_, Mar 20 2013
%E a(9)-a(12) from _Giovanni Resta_, Mar 21 2013
|