OFFSET
1,3
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
FORMULA
If n=p (prime), then a(n)=p-1. If n=2^m, then a(n)=1. [Corrected by R. J. Mathar, Nov 27 2007]
a(n) = 0 iff n is a Zumkeller number (A083207). - Amiram Eldar, Jan 05 2020
EXAMPLE
a(6) = 1 + 2 + 3 - 6 = 0.
MAPLE
A103977 := proc(n) local divs, a, acandid, filt, i, p, sigs ; divs := convert(numtheory[divisors](n), list) ; a := add(i, i=divs) ; for sigs from 0 to 2^nops(divs)-1 do filt := convert(sigs, base, 2) ; while nops(filt) < nops(divs) do filt := [op(filt), 0] ; od ; acandid := 0 ; for p from 0 to nops(divs)-1 do if op(p+1, filt) = 0 then acandid := acandid-op(p+1, divs) ; else acandid := acandid+op(p+1, divs) ; fi ; od: acandid := abs(acandid) ; if acandid < a then a := acandid ; fi ; od: RETURN(a) ; end: seq(A103977(n), n=1..80) ; # R. J. Mathar, Nov 27 2007
MATHEMATICA
a[n_] := Module[{d = Divisors[n], c, p, m}, c = CoefficientList[Product[1 + x^i, {i, d}], x]; p = -1 + Position[c, _?(# > 0 &)] // Flatten; m = Length[p]; If[OddQ[m], If[(d = p[[(m + 1)/2]] - p[[(m - 1)/2]]) == 1, 0, d], p[[m/2 + 1]] - p[[m/2]]]]; Array[a, 100] (* Amiram Eldar, Dec 11 2019 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Yasutoshi Kohmoto, Jan 01 2007
EXTENSIONS
More terms from R. J. Mathar, Nov 27 2007
STATUS
approved