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.

A216504 Number of values of k for which n can be written in the form a^2 + k*b^2, a >= 0, b >= 0, k > 0. a(n) = 0 if there are infinitely many such k.

Original entry on oeis.org

0, 2, 2, 0, 3, 3, 3, 5, 0, 4, 4, 5, 6, 4, 4, 0, 7, 6, 6, 7, 6, 6, 5, 8, 0, 6, 7, 8, 9, 6, 7, 10, 8, 8, 6, 0, 11, 7, 7, 11, 12, 7, 9, 11, 11, 8, 7, 11, 0, 9, 8, 13, 12, 10, 8, 12, 12, 10, 9, 11, 15, 8, 11, 0, 12, 9, 11, 15, 12, 10, 9, 17, 18, 10, 11, 16, 12, 9, 12, 15, 0, 12, 10, 14, 14, 11, 10, 17, 18, 13, 11, 15, 15, 12, 10, 17, 21, 12, 14, 0
Offset: 1

Views

Author

V. Raman, Sep 07 2012

Keywords

Comments

A number can be written as a^2+b^2 if and only if it has no prime factor congruent to 3 (mod 4) raised to an odd power.
A number can be written as a^2+2*b^2 if and only if it has no prime factor congruent to 5 (mod 8) or 7 (mod 8) raised to an odd power.
A number can be written as a^2+3*b^2 if and only if it has no prime factor congruent to 2 (mod 3) raised to an odd power.
A number can be written as a^2+7*b^2 if and only if it has no prime factor congruent to 3 (mod 7) or 5 (mod 7) or 6 (mod 7) raised to an odd power. Also the power of 2 should not be 1, if it can be written in the form a^2+7*b^2.
a(n) = 0 if and only if n is a square. - Charles R Greathouse IV, Sep 11 2012

Crossrefs

Programs

  • Maple
    N:= 100: # for a(1)..a(N)
    m:= floor(sqrt(N)):
    V:= Vector(N,i->{}):
    for a from 0 to m do
      for b from 1 to m do
        for k from 1 to floor((N-a^2)/b^2) do
          x:= a^2 + k*b^2;
          V[x]:= V[x] union {k};
    od od od:
    for i from 1 to N do
      if issqr(i) then V[i]:=0 else V[i]:= nops(V[i]) fi
    od:
    convert(V,list); # Robert Israel, Mar 06 2025
  • PARI
    for(n=1, 100, sol=0; for(k=1, n, for(x=0, n, if(issquare(n-k*x*x)&&n-k*x*x>=0, sol++; break))); if(issquare(n), print1(0", "), print1(sol", "))) /* V. Raman, Oct 16 2012 */