OFFSET
3,2
FORMULA
a(p) = A000720(p) - 1 for prime p. - R. J. Mathar, Apr 09 2008
EXAMPLE
a(10) = 9 because gcd(10,2) = 2, gcd(10,3) = 1, gcd(10,5) = 5, gcd(10,7) = 1; 2 + 1 + 5 + 1 = 9.
The underlying irregular table of gcd(n,2), gcd(n,3), gcd(n,5), gcd(n,7), etc., for which a(n) provides row sums, is obtained by deleting columns from A050873(n,k) and looks as follows for n=3,4,5,...:
1
2 1
1 1
2 3 1
1 1 1
2 1 1 1
1 3 1 1
2 1 5 1
1 1 1 1
2 3 1 1 1
1 1 1 1 1
2 1 1 7 1 1
1 3 5 1 1 1
2 1 1 1 1 1
1 1 1 1 1 1
2 3 1 1 1 1 1
1 1 1 1 1 1 1
2 1 5 1 1 1 1 1
MAPLE
A137324 := proc(n) local a, i; a :=0 ; for i from 1 to numtheory[pi](n-1) do a := a+gcd(n, ithprime(i)) ; od: a; end: seq(A137324(n), n=3..80) ; # R. J. Mathar, Apr 09 2008
MATHEMATICA
Table[Plus @@ GCD[n, Select[Range[n - 1], PrimeQ[ # ] &]], {n, 3, 70}] (* Stefan Steinerberger, Apr 09 2008 *)
PROG
(PARI) a(n) = sum(k=1, n-1, gcd(n, k)*isprime(k)); \\ Michel Marcus, Nov 07 2014
(Magma) [&+[Gcd(n, p):p in PrimesInInterval(1, n-1)]:n in [3..77]]; // Marius A. Burtea, Aug 07 2019
(Python)
from math import gcd
from sympy import primerange
def a(n): return sum(gcd(n, p) for p in primerange(1, n))
print([a(n) for n in range(3, 78)]) # Michael S. Branicky, Nov 21 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Max Sills, Apr 06 2008
EXTENSIONS
Corrected and extended by R. J. Mathar and Stefan Steinerberger, Apr 09 2008
STATUS
approved