OFFSET
1,3
COMMENTS
Equivalently, nonnegative k such that k*(k+1) is the sum of two squares.
Also, nonnegative k such that k*(k+1)/2 is the sum of two squares. This follows easily from the "sum of two squares theorem": x is the sum of two (nonnegative) squares iff its prime factorization does not contain p^e where p == 3 (mod 4) and e is odd. - Robert Israel, Mar 26 2018
Trivially, sequence includes all positive squares.
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10000
EXAMPLE
40 = 6^2 + 2^2, 41 = 5^2 + 4^2, so 40 is in the sequence.
MATHEMATICA
(*M6*) A1 = {}; Do[If[SquaresR[2, n (n + 1)/2] > 0, AppendTo[A1, n]], {n, 0, 1500}]; A1
Join[{0}, Flatten[Position[Accumulate[Range[500]], _?(SquaresR[2, #]> 0&)]]] (* Harvey P. Dale, Jun 07 2015 *)
SequencePosition[Table[If[SquaresR[2, n]>0, 1, 0], {n, 0, 500}], {1, 1}] [[All, 1]]-1 (* Harvey P. Dale, Jul 28 2021 *)
PROG
(Magma) [k:k in [0..460]| forall{k+a: a in [0, 1]|NormEquation(1, k+a) eq true}]; // Marius A. Burtea, Oct 08 2019
(Python)
from itertools import count, islice, starmap
from sympy import factorint
def A140612_gen(startvalue=0): # generator of terms >= startvalue
for k in count(max(startvalue, 0)):
if all(starmap(lambda d, e: e % 2 == 0 or d % 4 != 3, factorint(k*(k+1)).items())):
yield k
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Franklin T. Adams-Watters, May 19 2008
EXTENSIONS
a(1)=0 prepended and edited by Max Alekseyev, Oct 08 2019
STATUS
approved