OFFSET
1,3
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
Anders Hellström, Ruby program
FORMULA
a(n) ~ n, and in particular a(n) = n + O(n/sqrt(log n)). I do not know if this bound is tight. - Charles R Greathouse IV, Sep 01 2015
PROG
(PARI) issumsq(n, r, s)=(r^2)+(s^2)==n
first(m)=my(v=vector(m), x, r, n, s); v[1]=0; for(n=2, m, v[n]=v[n-1]+1; until(x==1, for(r=1, n-1, for(s=1, n-1, if(issumsq(v[n], v[r], v[s]), v[n]++; x=0; break(2), x=1))))); v;
(PARI) isA022544(n)=if(n%4==3, return(1)); my(f=factor(n)); for(i=1, #f~, if(f[i, 1]%4==3 && f[i, 2]%2, return(1))); 0
search(v, x)=my(t=setsearch(v, x)); if(t, t, setsearch(v, x, 1))
list(lim)=my(v=List([0, 1]), t); for(n=3, lim, if(isA022544(n), listput(v, n); next); for(j=search(v, sqrtint((n-1)\2)+1), search(v, sqrtint(n)), if(issquare(n-v[j]^2, &t) && setsearch(v, t), next(2))); listput(v, n)); Set(v) \\ Charles R Greathouse IV, Sep 01 2015
CROSSREFS
KEYWORD
nonn
AUTHOR
Anders Hellström, Aug 25 2015
STATUS
approved