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.

Showing 1-3 of 3 results.

A063987 Irregular triangle in which n-th row gives quadratic residues modulo the n-th prime.

Original entry on oeis.org

1, 1, 1, 4, 1, 2, 4, 1, 3, 4, 5, 9, 1, 3, 4, 9, 10, 12, 1, 2, 4, 8, 9, 13, 15, 16, 1, 4, 5, 6, 7, 9, 11, 16, 17, 1, 2, 3, 4, 6, 8, 9, 12, 13, 16, 18, 1, 4, 5, 6, 7, 9, 13, 16, 20, 22, 23, 24, 25, 28, 1, 2, 4, 5, 7, 8, 9, 10, 14, 16, 18, 19, 20, 25, 28, 1, 3, 4, 7, 9, 10, 11, 12, 16, 21, 25
Offset: 1

Views

Author

Suggested by Gary W. Adamson, Sep 18 2001

Keywords

Comments

For n >= 2, row lengths are (prime(n) - 1)/2. For example, since 17 is the 7th prime number, the length of row 7 is (17 - 1)/2 = 8. - Geoffrey Critzer, Apr 04 2015

Examples

			Modulo the 5th prime, 11, the (11 - 1)/2 = 5 quadratic residues are 1,3,4,5,9 and the 5 non-residues are 2, 6, 7, 8, 10.
The irregular triangle T(n, k) begins (p is prime(n)):
   n    p  \k 1 2 3 4  5  6  7  8  9 10 11 12 13 14
   1,   2:    1
   2,   3:    1
   3,   5:    1 4
   4,   7:    1 2 4
   5,  11:    1 3 4 5  9
   6:  13:    1 3 4 9 10 12
   7,  17:    1 2 4 8  9 13 15 16
   8,  19:    1 4 5 6  7  9 11 16 17
   9,  23:    1 2 3 4  6  8  9 12 13 16 18
  10,  29:    1 4 5 6  7  9 13 16 20 22 23 24 25 28
  ...  reformatted by _Wolfdieter Lang_, Mar 06 2016
		

References

  • Albert H. Beiler, Recreations in the theory of numbers, New York, Dover, (2nd ed.) 1966. See Table 82 at p. 202.

Crossrefs

Cf. A063988, A010379 (6th row), A010381 (7th row), A010385 (8th row), A010391 (9th row), A010392 (10th row), A278580 (row 23), A230077.
Cf. A076409 (row sums).
Cf. A046071 (for all n), A048152 (for all n, with 0's).

Programs

  • Maple
    with(numtheory): for n from 1 to 20 do for j from 1 to ithprime(n)-1 do if legendre(j, ithprime(n)) = 1 then printf(`%d,`,j) fi; od: od:
    # Alternative:
    QR := (a, n) -> NumberTheory:-QuadraticResidue(a, n):
    for n from 1 to 10 do p := ithprime(n):
    print(select(a -> 1 = QR(a, p), [seq(1..p-1)])) od:  # Peter Luschny, Jun 02 2024
  • Mathematica
    row[n_] := (p = Prime[n]; Select[ Range[p - 1], JacobiSymbol[#, p] == 1 &]); Flatten[ Table[ row[n], {n, 1, 12}]] (* Jean-François Alcover, Dec 21 2011 *)
  • PARI
    residue(n,m)=local(r);r=0;for(i=0,floor(m/2),if(i^2%m==n,r=1));r
    isA063987(n,m)=residue(n,prime(m)) /* Michael B. Porter, May 07 2010 */
    
  • PARI
    row(n) = my(p=prime(n)); select(x->issquare(Mod(x,p)), [1..p-1]); \\ Michel Marcus, Nov 07 2020
    
  • Python
    from sympy import jacobi_symbol as J, prime
    def a(n):
        p = prime(n)
        return [1] if n==1 else [i for i in range(1, p) if J(i, p)==1]
    for n in range(1, 11): print(a(n)) # Indranil Ghosh, May 27 2017
    
  • SageMath
    for p in prime_range(30): print(quadratic_residues(p)[1:])
    # Peter Luschny, Jun 02 2024

Extensions

Edited by Wolfdieter Lang, Mar 06 2016

A171555 Numbers of the form prime(n)*(prime(n)-1)/4.

Original entry on oeis.org

5, 39, 68, 203, 333, 410, 689, 915, 1314, 1958, 2328, 2525, 2943, 3164, 4658, 5513, 6123, 7439, 8145, 9264, 9653, 13053, 13514, 14460, 16448, 18023, 19113, 19670, 21389, 24414, 25043, 28308, 30363, 31064, 34689, 37733, 39303, 40100, 41718, 44205, 46764, 50288
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Dec 11 2009

Keywords

Comments

The halves of even numbers of the form p(p-1)/2 for p prime.
Sum of the quadratic residues of primes of the form 4k + 1. For example, a(3)=68 because 17 is the 3rd prime of the form 4k + 1 and the quadratic residues of 17 are 1, 4, 9, 16, 8, 2, 15, 13 which sum to 68. This sum is also the sum of the quadratic nonresidues. Cf. A230077. - Geoffrey Critzer, May 07 2015

References

  • R. Crandall and C. Pomerance, Prime Numbers: A Computational Perspective, Springer, NY, 2001; see Exercise 2.21 p. 110.

Crossrefs

Sums of residues, nonresidues, and their differences, for p == 1 (mod 4), p == 3 (mod 4), and all p: A171555; A282035, A282036, A282037; A076409, A125615, A282038.

Programs

  • Mathematica
    Table[Table[Mod[a^2, p], {a, 1, (p - 1)/2}] // Total, {p,
    Select[Prime[Range[100]], Mod[#, 4] == 1 &]}] (* Geoffrey Critzer, May 07 2015 *)
    Select[(# (#-1))/4&/@Prime[Range[100]],IntegerQ] (* Harvey P. Dale, Dec 24 2022 *)
  • PARI
    lista(nn) = forprime(p=2, nn, if ((p % 4)==1, print1(p*(p-1)/4, ", "))); \\ Michel Marcus, Mar 23 2016

Extensions

Corrected (16448 inserted, 25043 inserted) by R. J. Mathar, May 22 2010

A331047 T(n,k) = -(-1)^k*ceiling(k/2)^2 mod p, where p is the n-th prime congruent to 2 or 3 mod 4; triangle T(n,k), n>=1, 0<=k<=p-1, read by rows.

Original entry on oeis.org

0, 1, 0, 1, 2, 0, 1, 6, 4, 3, 2, 5, 0, 1, 10, 4, 7, 9, 2, 5, 6, 3, 8, 0, 1, 18, 4, 15, 9, 10, 16, 3, 6, 13, 17, 2, 11, 8, 7, 12, 5, 14, 0, 1, 22, 4, 19, 9, 14, 16, 7, 2, 21, 13, 10, 3, 20, 18, 5, 12, 11, 8, 15, 6, 17, 0, 1, 30, 4, 27, 9, 22, 16, 15, 25, 6, 5
Offset: 1

Views

Author

Alois P. Heinz, Jan 08 2020

Keywords

Comments

Row n is a permutation of {0, 1, ..., A045326(n)-1}.

Examples

			Triangle T(n,k) begins:
  0, 1;
  0, 1,  2;
  0, 1,  6, 4,  3, 2,  5;
  0, 1, 10, 4,  7, 9,  2,  5, 6, 3,  8;
  0, 1, 18, 4, 15, 9, 10, 16, 3, 6, 13, 17, 2, 11, 8, 7, 12, 5, 14;
  ...
		

Crossrefs

Columns k=0-2 give: A000004, A000012, A281664 (for n>1).
Last elements of rows give A190105(n-1) for n>1.
Row lengths give A045326.
Row sums give A000217(A281664(n)).

Programs

  • Maple
    b:= proc(n) option remember; local p;
          p:= 1+`if`(n=1, 1, b(n-1));
          while irem(p, 4)<2 do p:= nextprime(p) od; p
        end:
    T:= n-> (p-> seq(modp(-(-1)^k*ceil(k/2)^2, p), k=0..p-1))(b(n)):
    seq(T(n), n=1..8);
  • Mathematica
    b[n_] := b[n] = Module[{p}, p = 1+If[n == 1, 1, b[n-1]]; While[Mod[p, 4]<2, p = NextPrime[p]]; p];
    T[n_] := With[{p = b[n]}, Table[Mod[-(-1)^k*Ceiling[k/2]^2, p], {k, 0, p-1}]];
    Table[T[n], {n, 1, 8}] // Flatten (* Jean-François Alcover, Oct 29 2021, after Alois P. Heinz *)
Showing 1-3 of 3 results.