OFFSET
1,3
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
The divisors of twelve are {1, 2, 3, 4, 6 and 12}, the first difference is {1, 1, 1, 2 and 6}. The even differences add up to 8 while the odd differences add up to 3. The absolute difference between the even and odd first differences of 12 therefore is 5.
MAPLE
f:= proc(n) local Q, evens, odds;
Q:= sort(convert(numtheory:-divisors(n), list));
evens, odds:= selectremove(type, Q[2..-1]-Q[1..-2], even);
abs(convert(evens, `+`)-convert(odds, `+`))
end proc:
map(f, [$1..100]); # Robert Israel, Jul 05 2016
MATHEMATICA
f[ n_Integer ] := (d = Divisors[ n ]; l = Length[ d ]; s = 0; i = 1; While[ i < l, e = d[ [ i + 1 ] ] - d[ [ i ] ]; If[ EvenQ[ e ], s = s + e, s = s - e ]; i++ ]; Abs[ s ]); Table[ f[ n ], {n, 1, 75} ]
avd[n_]:=Module[{d=Differences[Divisors[n]]}, Abs[Total[Select[d, OddQ]]-Total[ Select[ d, EvenQ]]]]; Array[avd, 80] (* Harvey P. Dale, Dec 31 2018 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert G. Wilson v, Dec 16 2000
STATUS
approved