Chai Wah Wu, <a href="/A367142/b367142_1.txt">Table of n, a(n) for n = 0..87</a>
Chai Wah Wu, <a href="/A367142/b367142_1.txt">Table of n, a(n) for n = 0..87</a>
proposed
approved
editing
proposed
Chai Wah Wu, <a href="/A367142/b367142_1.txt">Table of n, a(n) for n = 0..87</a>
approved
editing
reviewed
approved
proposed
reviewed
editing
proposed
return sum(mobius(n//d)*c(d) for d in divisors(n, generator=True))//n-b(n-1) # Chai Wah Wu, Jul 03 2024
(Python)
from functools import lru_cache
from itertools import combinations
from fractions import Fraction
from math import prod, gcd, factorial
from sympy import mobius, divisors
from sympy.utilities.iterables import partitions
def A367142(n):
if n == 0: return 1
@lru_cache(maxsize=None)
def b(n): return int(sum(Fraction(1<<sum(p[r]*p[s]*gcd(r, s) for r, s in combinations(p.keys(), 2))+sum((q>>1)*r+(q*r*(r-1)>>1) for q, r in p.items()), prod(q**r*factorial(r) for q, r in p.items())) for p in partitions(n)))
@lru_cache(maxsize=None)
def c(n): return n*b(n)-sum(c(k)*b(n-k) for k in range(1, n))
return sum(mobius(n//d)*c(d) for d in divisors(n, generator=True))//n-b(n-1) # Chai Wah Wu, Jul 03 2024
approved
editing
proposed
approved