%I #10 Sep 27 2018 17:56:34
%S 1,1,-2,1,-2,-3,-2,2,0,-3,-2,-5,-2,-3,2,4,-2,0,-2,-5,2,-3,-2,-10,0,-3,
%T 0,-5,-2,3,-2,8,2,-3,2,0,-2,-3,2,-10,-2,3,-2,-5,0,-3,-2,-20,0,0,2,-5,
%U -2,0,2,-10,2,-3,-2,5,-2,-3,0,16,2,3,-2,-5,2,3,-2,0,-2,-3,0,-5,2,3,-2,-20,0,-3,-2,5,2,-3,2,-10,-2,0,2,-5,2,-3,2,-40,-2,0,0,0,-2,3
%N a(n) is defined recursively as the Sum{d|n} ((-1)^(n/d))*a(d) = 1, with a(1) = a(2) = 1.
%H Antti Karttunen, <a href="/A178412/b178412.txt">Table of n, a(n) for n = 1..65537</a>
%F 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.
%e 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.
%t 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 *)
%o (PARI)
%o up_to = 65537;
%o 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); };
%o v178412 = A178412list(up_to);
%o A178412(n) = v178412[n]; \\ _Antti Karttunen_, Sep 27 2018
%Y Cf. A178411.
%K sign
%O 1,3
%A _Vladimir Shevelev_, May 27 2010
%E Edited and extended by _Robert G. Wilson v_, Aug 26 2010
%E Title changed and terms past a(42) added by _Robert G. Wilson v_, Aug 26 2010