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 μ(n)\mu(n), with μ(0)=0\mu(0) = 0, or the values μ(0),…,μ(len−1)\mu(0), \ldots, \mu(\mathit{len} - 1).

n_moebius_mu uses μ(4n)=0\mu(4n) = 0 and μ(2n)=−μ(n)\mu(2n) = -\mu(n) for even nn, looks up odd nn up to a cutoff in a table storing μ(n)+1\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 pp and zeroes it at multiples of p2p^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-11-02).