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.

A373748 Triangle read by rows: T(n, k) is k if k is a quadratic residue modulo n, otherwise is -k and is a quadratic nonresidue modulo n. T(0, 0) = 0 by convention.

Original entry on oeis.org

0, 0, 1, 0, 1, 2, 0, 1, -2, 3, 0, 1, -2, -3, 4, 0, 1, -2, -3, 4, 5, 0, 1, -2, 3, 4, -5, 6, 0, 1, 2, -3, 4, -5, -6, 7, 0, 1, -2, -3, 4, -5, -6, -7, 8, 0, 1, -2, -3, 4, -5, -6, 7, -8, 9, 0, 1, -2, -3, 4, 5, 6, -7, -8, 9, 10, 0, 1, -2, 3, 4, 5, -6, -7, -8, 9, -10, 11, 0, 1, -2, -3, 4, -5, -6, -7, -8, 9, -10, -11, 12
Offset: 0

Views

Author

Peter Luschny, Jun 27 2024

Keywords

Examples

			Triangle starts:
  [0] [0]
  [1] [0,  1]
  [2] [0,  1,  2]
  [3] [0,  1, -2,  3]
  [4] [0,  1, -2, -3,  4]
  [5] [0,  1, -2, -3,  4,  5]
  [6] [0,  1, -2,  3,  4, -5,  6]
  [7] [0,  1,  2, -3,  4, -5, -6,  7]
  [8] [0,  1, -2, -3,  4, -5, -6, -7,  8]
  [9] [0,  1, -2, -3,  4, -5, -6,  7, -8,  9]
 [10] [0,  1, -2, -3,  4,  5,  6, -7, -8,  9,  10]
		

Crossrefs

Signed version of A002262.
Cf. A000004 (column 0), A001477 (main diagonal), A255644(n) + n (row sums).

Programs

  • Maple
    QR := (a, n) -> ifelse(n = 0, 1, NumberTheory:-QuadraticResidue(a, n)):
    for n from 0 to 10 do seq(a*QR(a, n), a = 0..n) od;
  • Mathematica
    qr[n_] := qr[n] = Join[Table[PowerMod[k, 2, n], {k, 0, Floor[n/2]}], {n}];
    T[0, 0] := 0; T[n_, k_] := If[MemberQ[qr[n], k], k, -k];
    Table[T[n, k], {n, 0, 11}, {k, 0, n}] // Flatten
  • SageMath
    def Trow(n):
        q = set(mod(a * a, n) for a in range(n // 2  + 1)).union({n})
        return [k if k in q else -k for k in range(n + 1)]
    for n in range(11): print(Trow(n))