|
|
A102548
|
|
Number of positive integers <= n that are expressible in the form u^2+v^2, with u and v integers.
|
|
3
|
|
|
1, 2, 2, 3, 4, 4, 4, 5, 6, 7, 7, 7, 8, 8, 8, 9, 10, 11, 11, 12, 12, 12, 12, 12, 13, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17, 18, 19, 19, 19, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 24, 24, 25, 26, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 30, 30, 30, 31, 31, 31, 31, 32, 33, 34, 34
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
FORMULA
|
a(n) = (partial sum of A229062 up to n) - 1. (End)
|
|
EXAMPLE
|
a(8) = 5 because 1 = 0^2 + 1^2, 2 = 1^2 + 1^2, 4 = 0^2 + 2^2, 5 = 1^2 + 2^2, 8 = 2^2 + 2^2, but 3,6 and 7 are not of the form u^2 + v^2, with u and v integers.
|
|
MAPLE
|
a := proc(n) local aux, i, m, u, v; aux:=0; for i from 1 to n do m:=floor(sqrt(i/2)); for u from 0 to m do v:=sqrt(i-u^2); if (v = floor(v)) then aux:=aux+1; u:=m; end if; end do; end do; aux; end proc:
|
|
MATHEMATICA
|
a[1]=1; a[n_]:= a[n]= a[n-1] + If[SquaresR[2, n]>0, 1, 0]; Table[a[n], {n, 75}] (* Jean-François Alcover, Mar 31 2015 *)
|
|
PROG
|
(PARI) first(n)= my(v = vector(n + 1), res = vector(n)); res[1] = 1; for(i = 0, sqrtint(n), for(j = i, sqrtint(n - i^2), v[i^2+j^2+1] = 1 ) ); for(i = 2, #res, res[i] = res[i-1] + v[i+1]; ); res \\ David A. Corneth, Jun 05 2020
(Python)
from itertools import count, accumulate, islice
from sympy import factorint
def A102548_gen(): # generator of terms
return accumulate(int(all(p & 3 != 3 or e & 1 == 0 for p, e in factorint(n).items())) for n in count(1))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
Salvador Perez Gomez (pies314(AT)hotmail.com), Feb 24 2005
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|