OFFSET
1,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{i=1..n} A000741(i). - Alois P. Heinz, Feb 08 2011
For n > 1, a(n) = n(n-1)(n-2)/6 - Sum_{j=2..n} a(floor(n/j)) = A000292(n-2) - Sum_{j=2..n} a(floor(n/j)). - Chai Wah Wu, Mar 30 2021
EXAMPLE
For n=6, the a(6) = 19 solutions are the binomial(6,3) = (6*5*4)/(1*2*3) = 20 possible triples minus the triple (2,4,6) with GCD=2.
MAPLE
f:=proc(n) local i, j, k, t1, t2, t3; t1:=0; for i from 1 to n-2 do for j from i+1 to n-1 do t2:=gcd(i, j); for k from j+1 to n do t3:=gcd(t2, k); if t3 = 1 then t1:=t1+1; fi; od: od: od: t1; end;
# program based on Moebius transform, partial sums of A000741:
with(numtheory):
b:= proc(n) option remember;
add(mobius(n/d)*(d-2)*(d-1)/2, d=divisors(n))
end:
a:= proc(n) option remember;
b(n) +`if`(n=1, 0, a(n-1))
end:
seq(a(n), n=1..100); # Alois P. Heinz, Feb 08 2011
MATHEMATICA
a[n_] := (cnt = 0; Do[cnt += Boole[GCD[i, j, k] == 1], {i, 1, n-2}, {j, i+1, n-1}, {k, j+1, n}]; cnt); Table[a[n], {n, 1, 45}] (* Jean-François Alcover, Mar 05 2013 *)
PROG
(PARI) print1(c=0); for(k=1, 99, for(j=1, k-1, gcd(j, k)==1 && (c+=j-1) && next; for(i=1, j-1, gcd([i, j, k])>1 || c++)); print1(", "c))
(Python)
from functools import lru_cache
@lru_cache(maxsize=None)
def A015616(n):
if n <= 1:
return 0
c, j = n*(n-1)*(n-2)//6, 2
k1 = n//j
while k1 > 1:
j2 = n//k1 + 1
c -= (j2-j)*A015616(k1)
j, k1 = j2, n//j2
return c # Chai Wah Wu, Mar 30 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved