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.

A373750 Middle terms of A373749.

Original entry on oeis.org

0, 0, 1, 1, 0, 4, 3, 2, 0, 7, 5, 3, 0, 10, 7, 4, 0, 13, 9, 5, 0, 16, 11, 6, 0, 19, 13, 7, 0, 22, 15, 8, 0, 25, 17, 9, 0, 28, 19, 10, 0, 31, 21, 11, 0, 34, 23, 12, 0, 37, 25, 13, 0, 40, 27, 14, 0, 43, 29, 15, 0, 46, 31, 16, 0, 49, 33, 17, 0, 52, 35, 18, 0, 55
Offset: 0

Views

Author

Peter Luschny, Jun 23 2024

Keywords

Crossrefs

Cf. A373749.

Programs

  • Maple
    REM := (n, k) -> ifelse(k = 0, n, irem(n, k)):
    T := n -> local k; seq(REM(k^2, n), k = 0..n):
    seq(T(n)[iquo(n, 2) + 1], n = 0..73);

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.

Original entry on oeis.org

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

Views

Author

Peter Luschny, Jun 27 2024

Keywords

Examples

			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]
		

Crossrefs

Signed version of A002262.
Cf. A000004 (column 0), A001477 (main diagonal), A255644(n) + n (row sums).

Programs

  • 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
  • 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))

A378298 Number of solutions that satisfy the congruence: i^2 == j^2 (mod n) with 1 <= i < j <= n.

Original entry on oeis.org

0, 0, 1, 2, 2, 2, 3, 8, 6, 4, 5, 14, 6, 6, 15, 24, 8, 12, 9, 26, 22, 10, 11, 48, 20, 12, 27, 38, 14, 30, 15, 64, 36, 16, 41, 66, 18, 18, 43, 88, 20, 44, 21, 62, 72, 22, 23, 136, 42, 40, 57, 74, 26, 54, 67, 128, 64, 28, 29, 150, 30, 30, 105, 160, 80, 72, 33, 98
Offset: 1

Views

Author

Darío Clavijo, Nov 22 2024

Keywords

Comments

a(n) >= A060594(n) for n >= 4.

Examples

			a(12) = 14 as the remainders 0 through 11 (mod 12) occur 2, 4, 0, 0, 4, 0, 0, 0, 0, 2, 0, 0 times respectively so a(12) = binomial(2, 2) + binomial(4, 2) + binomial(0, 2) + ... + binomial(0, 2) + binomial(0, 2) = 14. - _David A. Corneth_, Nov 25 2024
		

Crossrefs

Programs

  • Maple
    a:= n-> add(i*(i-1), i=coeffs(add(x^(j^2 mod n), j=1..n)))/2:
    seq(a(n), n=1..68);  # Alois P. Heinz, Nov 25 2024
  • Mathematica
    a[n_]:=Sum[Sum[Boole[PowerMod[i,2 , n ]== PowerMod[j,2 ,n]],{j,i+1,n}],{i,n}]; Array[a,68] (* Stefano Spezia, Nov 22 2024 *)
  • PARI
    a(n) = sum(i=1, n, sum(j=i+1, n, Mod(i, n)^2 == Mod(j, n)^2)); \\ Michel Marcus, Nov 25 2024
    
  • PARI
    a(n) = {
    	my(v = vector(n), res = 0);
    	for(i = 1, n,
    		v[(i^2%n)+1]++;	
    	);
    	sum(i = 1, n, binomial(v[i], 2))
    } \\ David A. Corneth, Nov 25 2024
  • Python
    from collections import defaultdict
    def a(n: int) -> int:
        s = defaultdict(int)
        for i in range(1, n+1):
            s[pow(i,2,n)] += 1
        return sum(k*(k-1)>>1 for k in s.values())
    print([a(n) for n in range(1, 69)])
    
  • Python
    from sympy import isprime
    def A378298(n):
        if isprime(n): return n-1>>1
        c, d = [0]*n, 0
        for i in range(n):
            d += c[m:=i**2%n]
            c[m] += 1
        return d # Chai Wah Wu, Nov 28 2024
    

Formula

a(n) = Sum_{i=1..n} Sum_{j=i+1..n} [i^2 mod n == j^2 mod n], where [] denotes the Iverson bracket.
a(n) = Sum_{i=1..n} Sum_{j=i+1..n} [A373749(n,i) = A373749(n,j)] , where [] denotes the Iverson bracket.
a(2^k) = A036289(k-1).
If p is an odd prime, then a(p) = (p-1)/2. - Chai Wah Wu, Nov 27 2024
Showing 1-3 of 3 results.