OFFSET
1,2
COMMENTS
The first negative term is a(330) = -21.
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..16384
FORMULA
a(n) = numerator of f(n), where f(1) = 1, f(n) = (1/2) * (A005187(n) - Sum_{d|n, d>1, d<n} f(d) * f(n/d)) for n > 1.
PROG
(PARI)
A005187(n) = { my(s=n); while(n>>=1, s+=n); s; };
A317927perA317928(n) = if(1==n, n, (A005187(n)-sumdiv(n, d, if((d>1)&&(d<n), A317927perA317928(d)*A317927perA317928(n/d), 0)))/2);
A317927(n) = numerator(A317927perA317928(n));
(PARI)
\\ Memoized implementation:
memo = Map();
A317927perA317928(n) = if(1==n, n, if(mapisdefined(memo, n), mapget(memo, n), my(v = (A005187(n)-sumdiv(n, d, if((d>1)&&(d<n), A317927perA317928(d)*A317927perA317928(n/d), 0)))/2); mapput(memo, n, v); (v)));
CROSSREFS
KEYWORD
sign,frac
AUTHOR
Antti Karttunen, Aug 11 2018
STATUS
approved