%I #15 Apr 20 2024 10:16:55
%S 1,1,1,1,3,9,1,5,7,9,19,1,3,4,1,2,4,8,1,3,5,9,15,17,25,27,31,1,7,9,11,
%T 13,15,19,25,29,41,43,1,4,5,6,7,9,13,1,3,5,9,11,15,23,25,27,33,41,43,
%U 45,49,55,1,3,4,7,9,10,11,12,16,1,2,4,5,8,9,10,16,18,20,1,3,7,9,13,17
%N Irregular triangle read by rows: n-th row gives congruence classes s such that the n-th prime q is a quadratic residue modulo an odd prime p if and only if p = plus or minus s for some s (mod m), where m = q if q is of the form 4k + 1, else m = 4q.
%C If n-th prime q is of the form 4k + 1, then by quadratic reciprocity row n consists of quadratic residues mod q, that are less than 2k; i.e., for q > 3, the first half of the corresponding row in A063987.
%C The first term in each row is always 1.
%e The 1st prime, 2, not of the form 4k + 1, is a square modulo odd primes p if and only if p = +/- 1 (mod 4*2 = 8).
%e The 6th prime, 13, of the form 4k + 1, is a square modulo odd primes p if and only if p = +/- 1, +/- 3, or +/- 4 (mod 13).
%e The irregular triangle T(n,k) begins (q is prime(n)):
%e n q \k 1 2 3 4 5 6 7 8 9 10 11
%e 1, 2: 1
%e 2, 3: 1
%e 3, 5: 1
%e 4, 7: 1 3 9
%e 5, 11: 1 5 7 9 19
%e 6: 13: 1 3 4
%e 7, 17: 1 2 4 8
%e 8, 19: 1 3 5 9 15 17 25 27 31
%e 9, 23: 1 7 9 11 13 15 19 25 29 41 43
%e 10, 29: 1 4 5 6 7 9 13
%o (Python)
%o from sympy import prime
%o def A371497_row(n):
%o q = prime(n)
%o res = {i*i % q for i in range(1, q//2 + 1)}
%o if q % 4 == 1:
%o res = {a for a in res if 2*a < q}
%o else:
%o res = {((a % 4 - 1) * q + a) % (4*q) for a in res}
%o res = {a if a < 2*q else 4*q - a for a in res}
%o return sorted(res)
%Y Cf. A063987, A081728.
%K nonn,tabf,easy
%O 1,5
%A _Nick Hobson_, Mar 25 2024