cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A102548 Number of positive integers <= n that are expressible in the form u^2+v^2, with u and v integers.

Original entry on oeis.org

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
Offset: 1

Views

Author

Salvador Perez Gomez (pies314(AT)hotmail.com), Feb 24 2005

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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))
    A102548_list = list(islice(A102548_gen(),30)) # Chai Wah Wu, Jun 28 2022

Formula

From David A. Corneth, Jun 05 2020: (Start)
A000161(a(n)) > 0.
a(n) = (partial sum of A229062 up to n) - 1. (End)
a(n) = n/sqrt(log n) * (K + B2/log n + O(1/log^2 n)), where K = A064533 and B2 = A227158. In particular, a(n) ~ Kn/sqrt(log n). - Charles R Greathouse IV, Dec 03 2022

Extensions

Name clarified by David A. Corneth, Jun 05 2020