login
a(n) = sum of second differences of the sorted divisors of n.
2

%I #34 Apr 06 2021 06:01:51

%S 0,0,1,0,2,0,3,4,4,0,5,0,6,8,7,0,8,0,9,12,10,0,11,16,12,16,13,0,14,0,

%T 15,20,16,24,17,0,18,24,19,0,20,0,21,28,22,0,23,36,24,32,25,0,26,40,

%U 27,36,28,0,29,0,30,40,31,48,32,0,33,44,34,0,35,0,36

%N a(n) = sum of second differences of the sorted divisors of n.

%C The sums of the first differences of the divisors of n are given by the sequence b(n) = n - 1.

%C 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)).

%H Antti Karttunen, <a href="/A330492/b330492.txt">Table of n, a(n) for n = 2..8191</a>

%H Antti Karttunen, <a href="/A330492/a330492.txt">Data supplement: n, a(n) computed for n = 2..65537</a>

%F a(n) = d(tau(n)) - d(tau(n) - 1) + d(1) - d(2) where d(i) are the divisors of n.

%F a(prime(n)) = 0 and a(2k) = k-1, k = 1, 2, ...

%F a(p^2) = (p-1)^2 if p prime, with the generalization a(p^m) = (p-1)(p^(m-1) - 1).

%F a(n) = (n/p-1)*(p-1), where p is the least prime factor of n. - _Nathaniel Gregg_, Apr 04 2021

%e 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.

%p with(numtheory):nn:=100:

%p for n from 2 to nn do:

%p d:=divisors(n):n0:=nops(d):T:=array(1..n0-1,[0$n0-1]):

%p for j from 1 to n0-1 do:

%p T[j]:=d[j+1]-d[j]:

%p od:

%p s:=sum(ā€˜T[i+1]-T[i] ā€™,ā€˜iā€™=1..n0-2): printf(`%d, `,s):

%p od:

%p *** alternative program using the formula ***

%p with(numtheory):nn:=100:

%p for n from 2 to nn do:

%p d:=divisors(n):t:=tau(n):s:=d[t]-d[t-1]+d[1]-d[2] :

%p printf(`%d, `,s):

%p od:

%t Array[Total@ Differences[Divisors@ #, 2] &, 73, 2] (* _Michael De Vlieger_, Dec 16 2019 *)

%o (PARI) a(n) = my(d=divisors(n)); d[#d] - d[#d-1] + d[1] - d[2]; \\ _Michel Marcus_, Feb 05 2020

%o (Python)

%o from sympy import primefactors

%o def a(n): p = primefactors(n)[0]; return (n//p - 1) * (p - 1)

%o print([a(n) for n in range(2, 75)]) # _Michael S. Branicky_, Apr 04 2021

%Y Cf. A000005, A027750, A036263, A193829.

%K nonn

%O 2,5

%A _Michel Lagneau_, Dec 16 2019