Documentation

Mathlib.Data.Nat.MaxPrimeFac

Greatest prime factor of a natural number #

This file defines Nat.maxPrimeFac, the greatest prime factor of a natural number greater than one, with explicit values at zero and one.

Implementation notes #

The list n.primeFactorsList is empty exactly when n = 0 or n = 1. We choose the junk values maxPrimeFac 0 = 0 and maxPrimeFac 1 = 1 so that:

Choosing maxPrimeFac 1 = 0 instead would make IsLUB {p : ℕ | p.Prime ∧ p ∣ n} (maxPrimeFac n) (but not IsGreatest {p : ℕ | p.Prime ∧ p ∣ n} (maxPrimeFac n)) hold for all n ≠ 0 and would make maxPrimeFac_eq_sSup hold unconditionally thanks to the junk value sSup ∅ = 0 on .

The greatest prime divisor of a natural number n > 1.

At the exceptional inputs n = 0 and n = 1, it returns the explicit default n because n.primeFactorsList is empty.

Equations
Instances For

    The greatest prime factor of a natural number divides it.

    theorem Nat.le_maxPrimeFac {n p : } (hn : n 0) (hp : Prime p) (h_dvd : p n) :

    Every prime factor of a nonzero natural number is at most its greatest prime factor.

    theorem Nat.isGreatest_maxPrimeFac {n : } (hn : 1 < n) :

    The greatest prime factor of a natural number greater than one is the greatest of its prime factors.

    theorem Nat.isLUB_maxPrimeFac {n : } (hn : 1 < n) :

    The greatest prime factor of a natural number greater than one is the least upper bound of its prime factors.

    theorem Nat.maxPrimeFac_le_iff {m n : } (hn : 1 < n) :
    n.maxPrimeFac m ∀ (p : ), Prime pp np m
    @[simp]
    theorem Nat.maxPrimeFac_mul {m n : } (hm : m 0) (hn : n 0) :

    The greatest prime factor of a product of nonzero natural numbers is the maximum of their greatest prime factors.

    @[simp]
    theorem Nat.maxPrimeFac_pow {k : } :
    k 0∀ (n : ), (n ^ k).maxPrimeFac = n.maxPrimeFac

    The greatest prime factor of a power with nonzero exponent is the greatest prime factor of its base.

    @[simp]

    The greatest prime factor of a prime is the prime itself.

    @[simp]

    The fixed points of maxPrimeFac are zero, one, and the primes.

    The greatest prime factor of a natural number is at most that number.

    theorem Nat.maxPrimeFac_eq_sSup {n : } (hn_one : n 1) :

    Away from n = 1, the computable greatest prime factor agrees with its supremum characterization.