FLINT3.7.0-dev

n_moebius_mu, n_moebius_mu_vec

Synopsis#include <flint/ulong_extras.h>
int n_moebius_mu(ulong n)source
void n_moebius_mu_vec(int * mu, ulong len)source

Compute the Möbius function \mu(n), with \mu(0) = 0, or the values \mu(0), \ldots, \mu(\mathit{len} - 1).

n_moebius_mu uses \mu(4n) = 0 and \mu(2n) = -\mu(n) for even n, looks up odd n up to a cutoff in a table storing \mu(n) + 1 in two bits, and otherwise checks for small odd square factors before calling n_factor. n_moebius_mu_vec sieves: it flips the sign of \mu at every multiple of each prime p and zeroes it at multiples of p^2.

Cite this page

The FLINT team, “n_moebius_mu, n_moebius_mu_vec (ulong_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/ulong_extras/n_moebius_mu.html (generated 2026-10-20).