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.

A381884 Triangle read by rows: T(n, k) = 0 if n = 0 or k is not a quadratic residue modulo n, otherwise T(n, k) = k.

Original entry on oeis.org

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

Views

Author

Peter Luschny, Mar 17 2025

Keywords

Examples

			Triangle T(n, k) starts:
  [0] 0;
  [1] 0, 1;
  [2] 0, 1, 2;
  [3] 0, 1, 0, 3;
  [4] 0, 1, 0, 0, 4;
  [5] 0, 1, 0, 0, 4, 5;
  [6] 0, 1, 0, 3, 4, 0, 6;
  [7] 0, 1, 2, 0, 4, 0, 0, 7;
  [8] 0, 1, 0, 0, 4, 0, 0, 0, 8;
  [9] 0, 1, 0, 0, 4, 0, 0, 7, 0, 9;
.
Array Arow(n) = [T(j, n), j = 0.. ] starts:
  [0] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
  [1] 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
  [2] 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, ...
  [3] 0, 3, 3, 3, 0, 0, 3, 0, 0, 0, ...
  [4] 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...
  [5] 0, 5, 5, 0, 5, 5, 0, 0, 0, 0, ...
  [6] 0, 6, 6, 6, 0, 6, 6, 0, 0, 0, ...
  [7] 0, 7, 7, 7, 0, 0, 7, 7, 0, 7, ...
  [8] 0, 8, 8, 0, 8, 0, 0, 8, 8, 0, ...
  [9] 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, ...
.
3 is not a quadratic residue modulo 7, therefore T(7, 3) = 0.
12 is a quadratic residue modulo 23, therefore T(23, 12) = 12.
		

Crossrefs

Indices of the nonzero terms in row n of the array: A057126 (row 2), A057125 (row 3), A057762 (row 5), A262931 (row 6), A262932 (row 7).

Programs

  • Maple
    QR := (k, n) -> ifelse(n = 0 or NumberTheory:-QuadraticResidue(k, n) < 0, 0, 1):
    T := (n, k) -> k*QR(k, n): seq(seq(T(n, k), k = 0..n), n = 0..12);
    Arow := (n, len) -> seq(T(j, n), j=0..len): seq(lprint([n], Arow(n, 9), n=0..9);
  • Mathematica
    QR[n_, k_] := Module[{x, y}, If[Reduce[x^2 == n + k*y, {x, y}, Integers] =!= False, 1, -1]];
    T[n_, k_] := If[n == 0 || QR[k, n] < 0, 0, k];
    Table[T[n, k], {n, 0, 12}, {k, 0, n}] // Flatten
  • Python
    from sympy.ntheory import is_quad_residue
    def QR(n, k): return is_quad_residue(n, k)
    def T(n, k): return 0 if n == 0 or not QR(k, n) else k
    for n in range(13): print([T(n, k) for k in range(n + 1)])