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.

A140612 Integers k such that both k and k+1 are the sum of 2 squares.

Original entry on oeis.org

0, 1, 4, 8, 9, 16, 17, 25, 36, 40, 49, 52, 64, 72, 73, 80, 81, 89, 97, 100, 116, 121, 136, 144, 145, 148, 169, 180, 193, 196, 225, 232, 233, 241, 244, 256, 260, 288, 289, 292, 305, 313, 324, 337, 360, 361, 369, 388, 400, 404, 409, 424, 441, 449, 457
Offset: 1

Views

Author

Keywords

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.

Examples

			40 = 6^2 + 2^2, 41 = 5^2 + 4^2, so 40 is in the sequence.
		

Crossrefs

Programs

  • 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
    
  • 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 *)
  • 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
    A140612_list = list(islice(A140612_gen(),20)) # Chai Wah Wu, Mar 07 2022

Extensions

a(1)=0 prepended and edited by Max Alekseyev, Oct 08 2019