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.

Showing 1-5 of 5 results.

A263715 Nonnegative integers that are the sum or difference of two squares.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 60, 61, 63, 64, 65, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80
Offset: 1

Views

Author

Jean-Christophe Hervé, Oct 24 2015

Keywords

Comments

Contains all integers that are not equal to 2 (mod 4) (they are of the form y^2 - x^2) and those of the form 4k+2 = 2*(2k+1) with the odd number 2k+1 equal to the sum of two squares (A057653).

Examples

			2 = 1^2 + 1^2, 3 = 2^2 - 1^2, 4 = 2^2 + 0^2, 5 = 2^2 + 1^2 = 3^2 - 2^2.
		

Crossrefs

Programs

  • Mathematica
    r[n_] := Reduce[n == x^2 + y^2, {x, y}, Integers] || Reduce[0 <= y <= x && n == x^2 - y^2, {x, y}, Integers]; Reap[Do[If[r[n] =!= False, Sow[n]], {n, 0, 80}]][[2, 1]] (* Jean-François Alcover, Oct 25 2015 *)
  • Python
    from itertools import count, islice
    from sympy import factorint
    def A263715_gen(): # generator of terms
        return filter(lambda n: n & 3 != 2 or all(p & 3 != 3 or e & 1 == 0 for p, e in factorint(n).items()),count(0))
    A263715_list = list(islice(A263715_gen(),30)) # Chai Wah Wu, Jun 28 2022

Formula

Union of A001481 (sums of two squares) and A042965 (differences of two squares).
Union of A042965 and 2*A057653 = A097269, with intersection of A042965 and A097269 = {}.
Union of A020668 (x^2+y^2 and a^2-b^2), A097269 (x^2+y^2, not a^2-b^2) and A263737 (not x^2+y^2, a^2-b^2).

A097271 Numbers that are neither the sum of two nonzero squares nor the difference of two nonzero squares.

Original entry on oeis.org

1, 4, 6, 14, 22, 30, 38, 42, 46, 54, 62, 66, 70, 78, 86, 94, 102, 110, 114, 118, 126, 134, 138, 142, 150, 154, 158, 166, 174, 182, 186, 190, 198, 206, 210, 214, 222, 230, 238, 246, 254, 258, 262, 266, 270, 278, 282, 286, 294, 302, 310, 318, 322, 326, 330, 334
Offset: 1

Views

Author

Ray Chandler, Aug 19 2004

Keywords

Comments

Complement of union of A000404 (sum of squares) and A024352 (difference of squares).
Differs from A062316 only in having an initial 1,4.

Crossrefs

Programs

  • Mathematica
    Module[{nn=70,sq},sq=Flatten[{Total[#],Abs[#[[1]]-#[[2]]]}&/@Tuples[ Range[ 3nn]^2,2]]//Union;Take[Complement[Range[Max[sq]],sq],nn]] (* Harvey P. Dale, Nov 04 2016 *)

A263737 Nonnegative integers that are the difference of two squares but not the sum of two squares.

Original entry on oeis.org

3, 7, 11, 12, 15, 19, 21, 23, 24, 27, 28, 31, 33, 35, 39, 43, 44, 47, 48, 51, 55, 56, 57, 59, 60, 63, 67, 69, 71, 75, 76, 77, 79, 83, 84, 87, 88, 91, 92, 93, 95, 96, 99, 103, 105, 107, 108, 111, 112, 115, 119, 120, 123, 124, 127, 129, 131, 132, 133, 135, 139, 140
Offset: 1

Views

Author

Jean-Christophe Hervé, Oct 25 2015

Keywords

Comments

Intersection of A022544 (not the sum of two squares) and A042965 (differences of two squares).
The sequence contains all 4k + 3 and no 4k + 2 integers, and some 4k (4*A022544) and 4k+1 (A084109) integers. First differences are thus 1, 2, 3 or 4, each occurring infinitely often.

Crossrefs

Programs

  • Mathematica
    rs[n_] := Reduce[n == x^2 + y^2, {x, y}, Integers]; rd[n_] := Reduce[0 <= y <= x && n == x^2 - y^2, {x, y}, Integers]; Reap[Do[If[rs[n] == False && rd[n] =!= False, Sow[n]], {n, 0, 140}]][[2, 1]] (* Jean-François Alcover, Oct 26 2015 *)
  • Python
    from itertools import count, islice
    from sympy import factorint
    def A263737_gen(): # generator of terms
        return filter(lambda n:n & 3 != 2 and any(p & 3 == 3 and e & 1 for p, e in factorint(n).items()),count(0))
    A263737_list = list(islice(A263737_gen(),30)) # Chai Wah Wu, Jun 28 2022

A088908 Numbers expressible as sum or difference of the squares of two distinct primes.

Original entry on oeis.org

5, 13, 16, 21, 24, 29, 34, 40, 45, 48, 53, 58, 72, 74, 96, 112, 117, 120, 125, 130, 144, 146, 160, 165, 168, 170, 173, 178, 192, 194, 218, 240, 264, 280, 285, 288, 290, 293, 298, 312, 314, 336, 338, 352, 357, 360, 365, 370, 386, 408, 410, 432, 458, 480, 482
Offset: 1

Views

Author

Hugo Pfoertner, Oct 22 2003

Keywords

Examples

			a(1)=3*3-2*2=5, a(2)=3*3+2*2=13, a(3)=5*5-3*3=16
		

Crossrefs

A263765 Minimum number of squares necessary to write n as a sum or difference of squares.

Original entry on oeis.org

1, 1, 2, 2, 1, 2, 3, 2, 2, 1, 2, 2, 2, 2, 3, 2, 1, 2, 2, 2, 2, 2, 3, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 1, 2, 3, 2, 2, 2, 3, 2, 2, 2, 3, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2
Offset: 0

Views

Author

Jean-Christophe Hervé, Oct 25 2015

Keywords

Comments

This sequence is equivalent to A002828 (least number of squares that add up to n) for sums and differences of squares. Here the possible forms include not only sums of squares, but also differences like x^2 - y^2 or x^2 + y^2 - z^2.
a(n) <= A002828(n) which is <= 4 (Lagrange's "Four Squares theorem"). In fact, a(n) <= 3: numbers of the form 4k, 4k+1 or 4k+3 are equal to the difference of two squares, therefore a(n) <= 2 in this case, and a(4k+2) <= 3 because 4k+2 = 4k+1+1^2. More precisely, a(4k) = 1 or 2; a(4k+1) = 1 or 2; a(4k+2) = 2 or 3; a(4k+3) = 2.
If A002828(n) = 4, a(n) = 2 (see A004215); if A002828(n) = 3, a(n) = 2 or 3: this shows that the form x^2 + y^2 - z^2 is never necessary to write an integer with the minimum number of squares; and of course, if A002828 = 1 or 2, a(n) = A002828.

Examples

			a(6) = 3 because 6 = 2^2 + 1^2 + 1^2 and 6 is not the sum or the difference of two squares; a(28) = 2 because 28 = 8^2 - 6^2.
		

Crossrefs

Formula

Using the partition of the natural numbers into A000290 (square numbers), A000415 (sum of 2 nonzero squares), A263737 (difference but not sum of 2 squares) and A062316 (neither the sum or difference of 2 squares), the sequence is completely defined by: a(A000290(n)) = 1, a(A000415(n)) = a(A263737(n)) = 2, a(A062316(n)) = 3.
Showing 1-5 of 5 results.