A263715 Nonnegative integers that are the sum or difference of two squares.
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
Keywords
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.
Links
- Jean-Christophe Hervé, Table of n, a(n) for n = 1..10000
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
Comments