login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A373354 Triangle read by rows: T(n, k) = [n - k + 1 | k] where [n | k] is defined below. 0

%I #11 Jun 03 2024 08:54:21

%S 1,1,1,1,1,1,1,2,3,1,1,2,1,3,1,1,2,2,3,3,1,1,2,0,1,0,3,1,1,1,1,1,1,1,

%T 1,1,1,2,2,3,1,2,3,3,1,1,2,0,3,2,3,2,0,3,1,1,2,2,1,0,1,0,1,3,3,1,1,2,

%U 2,1,0,2,3,0,1,3,3,1,1,2,3,3,2,0,1,0,3,2,2,3,1

%N Triangle read by rows: T(n, k) = [n - k + 1 | k] where [n | k] is defined below.

%H Carl Friedrich Gauss, <a href="http://gdz.sub.uni-goettingen.de/dms/load/img/?PID=PPN373456743%7CLOG_0008">Vierter Abschnitt. Von den Congruenzen zweiten Grades. Quadratische Reste und Nichtreste. Art. 97</a>, in "Untersuchungen über die höhere Arithmetik", Hrsg. H. Maser, Verlag von Julius Springer, Berlin, 1889.

%F Let two positive numbers n, k be given. We write (n R k) if two integers x and y exist, such that x^2 = n + k*y, and (n N k) otherwise. If the condition is satisfied n is called a quadratic residue modulo k. We distinguish four cases:

%F [n | k] := 0 if (n N k) and (k N n);

%F [n | k] := 1 if (n R k) and (k R n);

%F [n | k] := 2 if (n R k) and (k N n);

%F [n | k] := 3 if (n N k) and (k R n).

%F We set T(n, k) = [n - k + 1 | k].

%F Exchanging 2 <-> 3 reverses the rows.

%F All terms of row n are 1 <==> n = 1, 2 or n is of the form k*(k-2), k >= 3.

%e Triangle starts:

%e [ 1] 1;

%e [ 2] 1, 1;

%e [ 3] 1, 1, 1;

%e [ 4] 1, 2, 3, 1;

%e [ 5] 1, 2, 1, 3, 1;

%e [ 6] 1, 2, 2, 3, 3, 1;

%e [ 7] 1, 2, 0, 1, 0, 3, 1;

%e [ 8] 1, 1, 1, 1, 1, 1, 1, 1;

%e [ 9] 1, 2, 2, 3, 1, 2, 3, 3, 1;

%e [10] 1, 2, 0, 3, 2, 3, 2, 0, 3, 1;

%e [11] 1, 2, 2, 1, 0, 1, 0, 1, 3, 3, 1;

%e [12] 1, 2, 2, 1, 0, 2, 3, 0, 1, 3, 3, 1;

%p QRS := proc(n, k) local QR, p, q, a, b;

%p QR := (a, n) -> NumberTheory:-QuadraticResidue(a, n);

%p a := QR(n, k); b := QR(k, n);

%p if a = -1 and b = -1 then return 0 fi;

%p if a = 1 and b = 1 then return 1 fi;

%p if a = 1 and b = -1 then return 2 fi;

%p if a = -1 and b = 1 then return 3 fi;

%p end: for n from 1 to 12 do lprint([n], seq(QRS(n-k+1, k), k = 1..n)) od;

%o (Python)

%o from sympy.ntheory import is_quad_residue

%o def QR(n, k): return is_quad_residue(n, k)

%o def QRS(n, k):

%o a = QR(n, k); b = QR(k, n)

%o if not a and not b: return 0

%o if a and b: return 1

%o if a and not b: return 2

%o if not a and b: return 3

%o def T(n, k): return QRS(n - k + 1, k)

%o for n in range(1, 13): print([n], [T(n, k) for k in range(1, n + 1)])

%Y Cf. A373223, A373355 (restricted to primes).

%K nonn,tabl

%O 1,8

%A _Peter Luschny_, Jun 02 2024

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 13 09:59 EDT 2024. Contains 375904 sequences. (Running on oeis4.)