OFFSET
1,7
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = Sum_{k=1..floor((n-1)/2)} (n mod k) * floor(1/gcd(n,k)). - Wesley Ivan Hurt, Jan 18 2021
EXAMPLE
For n = 11, a(11) = (11 mod 1)+(11 mod 2)+(11 mod 3)+(11 mod 4)+(11 mod 5) = 7.
MAPLE
f:= proc(n) local k;
add(`if`(igcd(k, n)=1, n mod k, 0), k=1..floor(n/2))
end proc:
map(f, [$1..100]);
MATHEMATICA
Table[Sum[Mod[n, i]*Floor[1/GCD[i, n]], {i, Floor[(n - 1)/2]}], {n,
100}] (* Wesley Ivan Hurt, Jan 18 2021 *)
PROG
(PARI) a(n) = sum(k=1, n\2, if (gcd(k, n)==1, n%k)); \\ Michel Marcus, Jan 18 2021
(Python)
from math import gcd
def A340740(n): return sum(n % k for k in range(1, n//2+1) if gcd(k, n) == 1) # Chai Wah Wu, Mar 18 2021
CROSSREFS
KEYWORD
nonn,look
AUTHOR
J. M. Bergot and Robert Israel, Jan 18 2021
STATUS
approved