%I #58 Dec 18 2024 15:00:27
%S 1,1,-2,4,-2,-4,-2,12,2,-4,-2,-16,-2,-4,6,36,-2,8,-2,-16,6,-4,-2,-56,
%T 2,-4,-2,-16,-2,20,-2,108,6,-4,6,36,-2,-4,6,-56,-2,20,-2,-16,-10,-4,
%U -2,-192,2,8,6,-16,-2,-12,6,-56,6,-4,-2,88,-2,-4,-10,324,6
%N a(1)=1 and for n>=2 Sum_{k=1..n} a(k)*(-1)^floor(n/k)=0.
%C This sequence has properties related to primes (see ref and link). For instance a(n)=-4 iff n=2p, p odd prime, a(n) = 2 iff n=p^(2k) and a(n) = -2 iff n=p^(2k-1) for k>=1 where p is an odd prime etc. Moreover the sequence A(n)=a(1)+a(2)+...+a(n)=A195133(n) presents fractal aspects (see the scatterplot of A195133(n) for 2^k<n<2^(k+1) and various k).
%H Alois P. Heinz, <a href="/A194577/b194577.txt">Table of n, a(n) for n = 1..10000</a>
%H C. Cattani, <a href="http://dx.doi.org/10.1007/978-3-642-12165-4_14">Fractal patterns in prime numbers distribution</a>, Lecture Notes in Computer Science, 2010, Volume 6017/2010.
%H Benoit Cloitre, <a href="https://web.archive.org/web/20150923071043/http://bcmathematics.monsite-orange.fr/FractalOrderOfPrimes.pdf">On the fractal behavior of primes</a>, 2011.
%F A special case is a(2^k) = 4*3^(k-2) for k>=2 (for the complete formula involving divisors see pari-code).
%p a:= proc(n) option remember;
%p `if`(n=1, 1, add(a(k)*(-1)^floor(n/k), k=1..n-1))
%p end:
%p seq(a(n), n=1..100); # _Alois P. Heinz_, Sep 02 2011
%t a[1] = 1; a[n_] := a[n] = Sum[a[k]*(-1)^Floor[n/k], {k, 1, n-1}]; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Jun 12 2015 *)
%o (PARI) a(n)=if(n<3,1,if(n%2,-2*sumdiv(n,d,if(n-d,a(d),0)),2*sumdiv(n/2,d,a(d))-2*sumdiv(n/2^valuation(n,2),d,if(n/2^valuation(n,2)-d,a(2^valuation(n,2)*d),0))))
%Y Cf. A195133 (partial sums).
%K sign
%O 1,3
%A _Benoit Cloitre_, Aug 30 2011