OFFSET
1,3
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..65537
FORMULA
If n>=3 is odd squarefree (A056911), then a(n)=2; if n>=6 is even squarefree (A039956), then a(n)=3; if n>=4 has the form (2^k)*m, where k>=2 and m is odd squarefree, then a(n)=n/4 in case of m=1 and a(n)=5*2^(k-2) in case of m>1; if an odd square divides n, then a(n)=0. A generalization. Let A(n)=|B(n)|, where B(1)=f, B(2)=g and, for n>=3, B(n)is defined by the recursion: Sum{d|n}((-1)^(n/d))*B(d)=h. Then we have:if n>=3 is odd squarefree,then A(n)=f+h; if n>=6 is even squarefree,then A(n)=g+2*h; if n>=4 has the form (2^k)*m, where k>=2 and m is odd squarefree, then A(n)=n/4 in case of m=1 and A(n)=(f+g+3*h)*2^(k-2) in case of m>1; if an odd square divides n, then A(n)=0.
EXAMPLE
For n=3, we have Sum{d=1,3}((-1)^(3/d))*b(d)=-1-b(3)=1. Thus b(3)-2 and a(3)=2.
MATHEMATICA
a[1] = a[2] = 1; a[n_] := a[n] = Block[{d = Most@ Divisors@ n}, -1 + Plus @@ (((-1)^(n/#)) a[ # ] & /@ d)]; Array[a, 102] (* Robert G. Wilson v, Aug 26 2010 *)
PROG
(PARI)
up_to = 65537;
A178412list(up_to) = { my(u=vector(up_to)); u[1] = u[2] = 1; for(n=3, up_to, u[n] = sumdiv(n, d, if(d<n, ((-1)^(n/d))*u[d]))-1); (u); };
v178412 = A178412list(up_to);
A178412(n) = v178412[n]; \\ Antti Karttunen, Sep 27 2018
CROSSREFS
KEYWORD
sign
AUTHOR
Vladimir Shevelev, May 27 2010
EXTENSIONS
Edited and extended by Robert G. Wilson v, Aug 26 2010
Title changed and terms past a(42) added by Robert G. Wilson v, Aug 26 2010
STATUS
approved