|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
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.
|
|
LINKS
|
|
|
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
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,hard,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|