OFFSET
1,6
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..1000
Oliver Knill, Some experiments in number theory, arXiv preprint arXiv:1606.05971 [math.NT], 2016.
FORMULA
a(p) = a(p-1) when p is prime.
a(n)-a(n-1) = A016035(n).
a(n) = n*(n-1)/2 + 1 - Sum_{i=1..n} phi(i).
EXAMPLE
For n=9, the a(9)=9 pairs are {(2,4),(2,6),(2,8),(3,6),(3,9),(4,6),(4,8),(6,8),(6,9)}.
MAPLE
with(numtheory): A185670:=n->n*(n-1)/2 + 1 - add( phi(i), i=1..n): seq(A185670(n), n=1..100); # Wesley Ivan Hurt, Jan 30 2017
MATHEMATICA
1 + Accumulate[ Table[n - EulerPhi[n] - 1, {n, 1, 75}]] (* Jean-François Alcover, Jan 04 2013 *)
PROG
(Haskell)
a185670 n = length [(x, y) | x <- [1..n-1], y <- [x+1..n], gcd x y > 1]
-- Reinhard Zumkeller, Mar 02 2012
(Python)
from functools import lru_cache
@lru_cache(maxsize=None)
if n == 0:
return 0
c, j = 2, 2
k1 = n//j
while k1 > 1:
j2 = n//k1 + 1
c += (j2-j)*(k1*(k1-1)+1-2*A185670(k1))
j, k1 = j2, n//j2
return (c-j)//2 # Chai Wah Wu, Mar 24 2021
(PARI) a185670(n) = sum(i=2, n, sum(j=2, i-1, gcd(i, j)>1)) \\ Hugo Pfoertner, Sep 04 2024
CROSSREFS
KEYWORD
nonn,easy,nice
AUTHOR
Olivier Gérard, Feb 09 2011
EXTENSIONS
Definition clarified by Reinhard Zumkeller, Mar 02 2012
STATUS
approved