OFFSET
1,4
LINKS
FORMULA
a(n) = numerator of f(n), where f(1) = 1, f(n) = (1/2) * (A002487(n) - Sum_{d|n, d>1, d<n} f(d) * f(n/d)) for n > 1.
PROG
(PARI)
A002487(n) = { my(a=1, b=0); while(n>0, if(bitand(n, 1), b+=a, a+=b); n>>=1); (b); }; \\ From A002487
A317931perA317932(n) = if(1==n, n, (A002487(n)-sumdiv(n, d, if((d>1)&&(d<n), A317931perA317932(d)*A317931perA317932(n/d), 0)))/2);
A317931(n) = numerator(A317931perA317932(n));
(PARI)
\\ Memoized implementation:
memo = Map();
A317931perA317932(n) = if(1==n, n, if(mapisdefined(memo, n), mapget(memo, n), my(v = (A002487(n)-sumdiv(n, d, if((d>1)&&(d<n), A317931perA317932(d)*A317931perA317932(n/d), 0)))/2); mapput(memo, n, v); (v)));
CROSSREFS
KEYWORD
AUTHOR
Antti Karttunen, Aug 11 2018
STATUS
approved