login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
5
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,6
LINKS
Carl Friedrich Gauss, Vierter Abschnitt. Von den Congruenzen zweiten Grades. Quadratische Reste und Nichtreste. Art. 97, in "Untersuchungen über die höhere Arithmetik", Hrsg. H. Maser, Verlag von Julius Springer, Berlin, 1889.
EXAMPLE
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]
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
PROG
(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))
CROSSREFS
Signed version of A002262.
Cf. A000004 (column 0), A001477 (main diagonal), A255644(n) + n (row sums).
Sequence in context: A166352 A025690 A025668 * A048151 A025675 A025682
KEYWORD
sign,tabl
AUTHOR
Peter Luschny, Jun 27 2024
STATUS
approved