AngouriMath

Try it live

Navigation

← Back to list of members

Factorize​(AngouriMath.​Entity.​Number.​Integer)

 Method (no overloads)

Summary

The prime factorisation of a positive integer: each prime that divides it with its
power, the smallest prime first. Empty for 1, the empty product.

Exception "InvalidNumberException"

Thrown where integer is 0 or negative, which have no factorisation
into primes alone. https://github.com/asc-community/AngouriMath/issues/2466

Example

var factors = MathS.NumberTheory.Factorize(1872);
foreach (var (prime, power) in factors)
    Console.WriteLine($"{prime} ^ {power}");

Prints
2 ^ 4
3 ^ 2
13 ^ 1

























Angouri © 2019-2026 · Project's repo · Site's repo · Octicons · Transparency · 6091 pages online