PrimeNu¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
PrimeNu[n] gives the number of distinct prime factors of n, nu(n). PrimeNu[n, GaussianIntegers -> True] (or a non-real Gaussian-integer n) counts distinct Gaussian prime factors over Z[i]. PrimeNu[1] is 0; PrimeNu[0] is left unevaluated.
Examples (6)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (5)¶
In[1]:= PrimeNu[24]
Out[1]= 2
In[2]:= PrimeNu[105]
Out[2]= 3
In[3]:= PrimeNu[{4, 28, 180}]
Out[3]= {1, 2, 3}
In[4]:= PrimeNu[50!]
Out[4]= 15
In[5]:= PrimeNu[3 + I]
Out[5]= 2
Options (1)¶
Algorithm¶
primenu.c -- PrimeNu[]. Split from numbertheory.c; see numbertheory.h and numbertheory_internal.h for the subsystem layout.
additive companion to PrimeOmega (which counts prime factors with multiplicity): for n = u p_1^k_1 ... p_m^k_m with u a unit and p_i distinct
primes, PrimeNu[n] returns m. nu and Omega coincide exactly when n is
square-free. PrimeNu shares all factoring machinery and argument handling
with PrimeOmega/LiouvilleLambda; it simply returns the count of factors rather than the sum of the exponents.
Implementation notes¶
Listable,Protected.- Additive on coprime arguments:
nu(m n) = nu(m) + nu(n)whenGCD[m, n] == 1. - Computed directly from the prime factorisation (machine integers and GMP bigints handled uniformly).
PrimeNu[1](andPrimeNu[-1]) is0; the sign ofnis ignored (nu(-n) = nu(n)).- Gaussian integers:
PrimeNu[n, GaussianIntegers -> True], or a non-real Gaussian-integer argumentComplex[a, b], factorsnoverZ[i]and counts the distinct Gaussian prime factors. Because a rational primep ≡ 1 (mod 4)splits into two conjugate Gaussian primes, e.g.PrimeNu[105, GaussianIntegers -> True]is4(from3, the split pair over5, and7) whilePrimeNu[105]is3. - Non-integer or zero
nis left unevaluated; a wrong argument count issues aPrimeNu::argtmessage. - Relations: for a square-free
n,MoebiusMu[n] == (-1)^PrimeNu[n]andLiouvilleLambda[n] == (-1)^PrimeNu[n].
Attributes: Listable, Protected.
References¶
See also: PrimeOmega
- Source:
src/info.c - Specification:
docs/spec/builtins/number-theory.md - Tests:
tests/test_primenu.c