OFFSET
2,5
COMMENTS
The sums of the first differences of the divisors of n are given by the sequence b(n) = n - 1.
Let the set {D(i)} = {d(i + 1) - d(i)} where the d(i) are the divisors of an integer m listed in ascending order with i = 1, 2 , ..., tau(n)-1. The sequence is given by a(n) = Sum_{k = 1..tau(n)-2} (D(k + 1) - D(k)).
LINKS
Antti Karttunen, Table of n, a(n) for n = 2..8191
Antti Karttunen, Data supplement: n, a(n) computed for n = 2..65537
FORMULA
a(n) = d(tau(n)) - d(tau(n) - 1) + d(1) - d(2) where d(i) are the divisors of n.
a(prime(n)) = 0 and a(2k) = k-1, k = 1, 2, ...
a(p^2) = (p-1)^2 if p prime, with the generalization a(p^m) = (p-1)(p^(m-1) - 1).
a(n) = (n/p-1)*(p-1), where p is the least prime factor of n. - Nathaniel Gregg, Apr 04 2021
EXAMPLE
a(12) = 5 because the divisors of 12 are {1, 2, 3, 4, 6, 12} and {D(i)} = {d(i+1)-d(i)} ={1, 1, 1, 2, 6}, Sum_{D(i), i = 1..4} {D(i+1)-D(i)} = 0 + 0 + 1 + 4 = 5.
MAPLE
with(numtheory):nn:=100:
for n from 2 to nn do:
d:=divisors(n):n0:=nops(d):T:=array(1..n0-1, [0$n0-1]):
for j from 1 to n0-1 do:
T[j]:=d[j+1]-d[j]:
od:
s:=sum(āT[i+1]-T[i] ā, āiā=1..n0-2): printf(`%d, `, s):
od:
*** alternative program using the formula ***
with(numtheory):nn:=100:
for n from 2 to nn do:
d:=divisors(n):t:=tau(n):s:=d[t]-d[t-1]+d[1]-d[2] :
printf(`%d, `, s):
od:
MATHEMATICA
Array[Total@ Differences[Divisors@ #, 2] &, 73, 2] (* Michael De Vlieger, Dec 16 2019 *)
PROG
(PARI) a(n) = my(d=divisors(n)); d[#d] - d[#d-1] + d[1] - d[2]; \\ Michel Marcus, Feb 05 2020
(Python)
from sympy import primefactors
def a(n): p = primefactors(n)[0]; return (n//p - 1) * (p - 1)
print([a(n) for n in range(2, 75)]) # Michael S. Branicky, Apr 04 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Dec 16 2019
STATUS
approved