login
A309288
a(0) = 0, a(1) = 1, and for any n > 1, a(n) = Sum_{k > 1} (-1)^k * a(floor(n/k)).
8
0, 1, 1, 0, 1, 0, 0, -1, 1, 1, 1, 0, -1, -2, -2, -1, 3, 2, 2, 1, 0, 1, 1, 0, -2, -2, -2, -2, -3, -4, -4, -5, 3, 4, 4, 5, 5, 4, 4, 5, 3, 2, 2, 1, 0, 0, 0, -1, -5, -5, -5, -4, -5, -6, -6, -5, -7, -6, -6, -7, -6, -7, -7, -7, 9, 10, 10, 9, 8, 9, 9, 8, 8, 7, 7, 7
OFFSET
0,14
COMMENTS
This sequence is a signed variant of A022825.
LINKS
FORMULA
G.f. A(x) satisfies -x * (1 - x) = Sum_{k>=1} (-1)^k * (1 - x^k) * A(x^k). - Seiichi Manyama, Mar 31 2023
EXAMPLE
a(3) = a(floor(3/2)) - a(floor(3/3)) = a(1) - a(1) = 0.
MATHEMATICA
Join[{0}, Clear[a]; a[0]=0; a[1]=1; a[n_]:=a[n]=Sum[a[Floor[n/k]](-1)^k, {k, 2, n}]; Table[a[n], {n, 1, 100}]] (* Vincenzo Librandi, Jul 22 2019 *)
f[p_, e_] := If[e == 1, -1, 0]; f[2, e_] := If[e == 1, 0, 2^(e-2)]; s[1] = 1; s[n_] := Times @@ f @@@ FactorInteger[n]; Join[{0}, Accumulate[Array[s, 100]]] (* Amiram Eldar, May 09 2023 *)
PROG
(PARI) a(n) = if (n<=1, n, sum (k=2, n, (-1)^k * a(n\k)))
(Python)
from functools import lru_cache
@lru_cache(maxsize=None)
def A309288(n):
if n <= 1:
return n
c, j = 0, 2
k1 = n//j
while k1 > 1:
j2 = n//k1 + 1
c += ((j2-j)%2)*(1-2*(j%2))*A309288(k1)
j, k1 = j2, n//j2
return c+((n+1-j)%2)*(1-2*(j%2)) # Chai Wah Wu, Mar 31 2021
CROSSREFS
Cf. A022825.
Sequence in context: A341372 A363193 A124018 * A235061 A355244 A364730
KEYWORD
sign,look
AUTHOR
Rémy Sigrist, Jul 21 2019
STATUS
approved