OFFSET
1,8
COMMENTS
David James Sycamore and Karl Love computed this sequence in early October 2018 and studied its asymptotic growth.
See link for conjectured asymptotic behavior of this sequence, showing (red line) first asymptotic term and residual bounds (blue lines). It appears that a(n) ~ Li(p)^2/(2*p), based upon the assumption that the probabilities that the first and second numbers in a pair are primes are independent. The residuals (with minor exceptions for some small p) seem to be bounded by (2/Pi^2)*sqrt(p). These observations were contributed by Karl Love (via Mapleprimes). - David James Sycamore, Nov 05 2018
If i < j < p in the definition is replaced by i <= j < p, then the only change is that a(2) becomes 1. For if i^2 == 1 (mod p) then p divides i^2-1 = (i-1)*(i+1), which implies p=i+1, so p must be 3 and i must be 2. - N. J. A. Sloane, Nov 06 2018
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
Karl Love, Maple programs for A321005
David James Sycamore, Asymptotic Behaviour of A321005
FORMULA
An alternative heuristic argument leads the conjecture that a(n) ~ (n-4)/(2*log(n)) ~ Pi(n)/2. (Essentially the same as Karl Love's conjecture in the Comments section, but simpler to calculate.) - N. J. A. Sloane, Nov 06 2018
MAPLE
with(numtheory);
f:=proc(n) local m, i, j, c; global pi;
if n < 4 then return(0); fi;
c:=0; m:=NumberTheory[pi](n); if isprime(n) then m:=m-1; fi;
for i from 1 to m-1 do p:=ithprime(i);
for j from i+1 to m do
if ithprime(j)*p mod n = 1 then c:=c+1; fi; od: od: c; end;
[seq(f(ithprime(n)), n=1..120)];
MATHEMATICA
a[n_] := Module[{p=Prime[n]}, c=0; Do[Do[If[Mod[Prime[i]*Prime[j], p]==1, c++], {i, 1, j-1}], {j, 1, n-1} ]; c]; Array[a, 100] (* Amiram Eldar, Jan 11 2019 *)
PROG
(Python)
from sympy import nextprime
A321005_list, plist = [], [2]
for n in range(10000):
c, p = 0, plist[-1]
for j in range(n):
pj = plist[j]
for i in range(j):
if (plist[i]*pj) % p == 1:
c += 1
A321005_list.append(c)
plist.append(nextprime(p)) # Chai Wah Wu, Nov 02 2018
(PARI) a(n) = my(vp = primes(n)); sum(i=1, n-2, sum(j=i+1, n-1, (vp[i]*vp[j] % vp[n]) == 1)); \\ Michel Marcus, Jan 11 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Nov 02 2018, following a suggestion from David James Sycamore
STATUS
approved