OFFSET
1,8
COMMENTS
Equivalently, i and j must have the same slope (prime(n) - prime(i))/(n - i). Hence, a(n) is the sum of the number of ways one can choose two among all indices that have a given slope s, over all possible values s, see Formula. - M. F. Hasler, Apr 12 2026
With prime(111), it is the first time that prime(1) gets involved, as (prime(111) - prime(1))/(111 - 1) == (prime(111) - prime(103))/(111 - 103) == 11/2. - Ruud H.G. van Tol, Apr 23 2026
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{s in S} binomial(m(s), 2), with S = { slope(i); 0 < i < n }, slope(i) = (prime(n) - prime(i))/(n - i) and m(s) = #{ i < n : slope(i) = s }. - M. F. Hasler, Apr 12 2026
EXAMPLE
a(4) = 1 because the only set of triples in this case is {(2, 3), (3, 5), (4, 7)}: these three are on a line of slope 2.
a(100) = 4: the four triples are {(27, 103), (31, 127), (100, 541)}, {(60, 281), (72, 359), (100, 541)}, {(79, 401), (82, 421), (100, 541)}, {(86, 443), (88, 457), (100, 541)}.
PROG
(PARI) isok(v1, v2, v3) = (v3[2] - v2[2])/(v3[1] - v2[1]) == (v2[2] - v1[2])/(v2[1] - v1[1]);
a(n) = my(pn=prime(n)); sum(i=1, n-1, my(pi=prime(i)); sum(j=i+1, n-1, isok([i, pi], [j, prime(j)], [n, pn]))); \\ Michel Marcus, Apr 10 2026
(PARI) apply( {A390812(n)=my(p=primes(n), L); sum(i=1, #p=vecsort([(p[n]-p[i])/(n-i)|i<-[1..n-1]]), if(i+1==n||p[i]!=p[i+1], binomial(-L+L=i, 2)))}, [1..99]) \\ M. F. Hasler, Apr 12 2026
(PARI) A390812(n)=if(n>1, my(M=Map(), p=primes(n), f); for(i=1, n-1, mapput(M, f=(p[n]-p[i])/(n-i), iferr(mapget(M, f), E, )+1)); vecsum([t*(t-1)\2|t<-Mat(M)[, 2], t>1])) \\ M. F. Hasler, Apr 12 2026
CROSSREFS
KEYWORD
nonn
AUTHOR
Firdous Ahmad Mala, Apr 09 2026
STATUS
approved
