OFFSET
1,4
COMMENTS
a(n) >= A060594(n) for n >= 4.
LINKS
Darío Clavijo, Python program, Github.
FORMULA
EXAMPLE
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
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 *)
PROG
(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)])
(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
CROSSREFS
KEYWORD
nonn,changed
AUTHOR
Darío Clavijo, Nov 22 2024
STATUS
editing