login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A370681
a(n) is the alternating sum of the unitary divisors of n, when these divisors are starting with n and decreasing.
3
1, 1, 2, 3, 4, 4, 6, 7, 8, 6, 10, 10, 12, 8, 12, 15, 16, 10, 18, 18, 16, 12, 22, 18, 24, 14, 26, 24, 28, 22, 30, 31, 24, 18, 32, 30, 36, 20, 28, 36, 40, 32, 42, 36, 40, 24, 46, 34, 48, 26, 36, 42, 52, 28, 48, 54, 40, 30, 58, 46, 60, 32, 60, 63, 56, 48, 66, 54
OFFSET
1,3
COMMENTS
a(n) is odd if and only if n is a power of 2.
LINKS
FORMULA
a(n) = A071324(n) if n is squarefree (A005117) or if n is in A370683.
EXAMPLE
The unitary divisors of 6 are {1, 2, 3, 6}, hence a(6) = 6 - 3 + 2 - 1 = 4.
The unitary divisors of 12 are {1, 3, 4, 12}, hence a(12) = 12 - 4 + 3 - 1 = 10.
MATHEMATICA
a[n_] := Module[{d = Reverse[Select[Divisors[n], CoprimeQ[#, n/#] &]]}, Total[(-1)^(Range[Length[d]] + 1)*d]]; Array[a, 100]
PROG
(PARI) a(n) = {my(d = Vecrev(select(x->(gcd(x, n/x) == 1), divisors(n)))); sum(i=1, #d, (-1)^(i+1)*d[i]); }
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Amiram Eldar, Feb 26 2024
STATUS
approved