login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A217705
Smallest number greater than 1 that is happy under bases 2 through n.
2
2, 3, 3, 23, 79, 2207, 58775, 569669, 11814485, 210511543, 73748383237
OFFSET
2,1
COMMENTS
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.
All numbers are happy in binary and base 4.
EXAMPLE
a(8) = 58775 because:
Base 2: 1110010110010111 - 1010 - 10 - 1,
Base 3: 2222121212 - 1011 - 10 - 1,
Base 4: 321121113 - 132 - 32 - 31 - 22 - 20 - 10 - 1,
Base 5: 3340100 - 120 - 10 - 1,
Base 6: 1132035 - 121 - 10 - 1,
Base 7: 333233 - 100 - 1,
Base 8: 162627 - 202 - 10 - 1,
Base 9 fails since the end is the 58 - 108 - 72 cycle and fails to reach 1.
PROG
(PARI) ssd(n, b)=my(s); while(n, s+=(n%b)^2; n\=b); s
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
h3(k)=while(k>8, k=ssd(k, 3)); k==1 || k==3
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
KEYWORD
base,hard,nonn
AUTHOR
Sergio Pimentel, Mar 20 2013
EXTENSIONS
a(9)-a(12) from Giovanni Resta, Mar 21 2013
STATUS
approved