login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A347030
a(n) = 1 + Sum_{k=2..n} (-1)^k * a(floor(n/k)).
4
1, 2, 1, 3, 2, 1, 0, 4, 4, 3, 2, 0, -1, -2, -1, 7, 6, 6, 5, 3, 4, 3, 2, -2, -2, -3, -3, -5, -6, -5, -6, 10, 11, 10, 11, 11, 10, 9, 10, 6, 5, 6, 5, 3, 3, 2, 1, -7, -7, -7, -6, -8, -9, -9, -8, -12, -11, -12, -13, -11, -12, -13, -13, 19, 20, 21, 20, 18, 19, 20, 19, 19, 18, 17, 17
OFFSET
1,2
COMMENTS
Partial sums of A067856.
FORMULA
G.f. A(x) satisfies: A(x) = (1/(1 - x)) * (x + Sum_{k>=2} (-1)^k * (1 - x^k) * A(x^k)).
MATHEMATICA
a[n_] := a[n] = 1 + Sum[(-1)^k a[Floor[n/k]], {k, 2, n}]; Table[a[n], {n, 1, 75}]
nmax = 75; A[_] = 0; Do[A[x_] = (1/(1 - x)) (x + Sum[(-1)^k (1 - x^k) A[x^k], {k, 2, nmax}]) + O[x]^(nmax + 1) // Normal, nmax + 1]; CoefficientList[A[x], x] // Rest
PROG
(Python)
from functools import lru_cache
@lru_cache(maxsize=None)
def A347030(n):
if n <= 1:
return n
c, j = 1, 2
k1 = n//j
while k1 > 1:
j2 = n//k1 + 1
c += (j2-j&1)*(-1 if j&1 else 1)*A347030(k1)
j, k1 = j2, n//j2
return c+(n+1-j&1)*(-1 if j&1 else 1) # Chai Wah Wu, Apr 04 2023
CROSSREFS
KEYWORD
sign
AUTHOR
Ilya Gutkovskiy, Aug 11 2021
STATUS
approved