#factor #const #factorization #number-theory #no-std #prime-factors

no-std machine-factor

constant factorisation for machine-size integers

1 unstable release

new 0.2.0 Jan 29, 2025
0.1.0 Jan 26, 2025

#1343 in Math

Download history 87/week @ 2025-01-22

87 downloads per month

CC0 license

16KB
416 lines

Machine Factor

Relatively fast factorisation library for n < 2^128. Approximately 3 times faster than GNU Factor.

Permits constant-time evaluation, although this is impractical for 128-bit integers.

Provides a C-style api.

Note that this library uses Pollard-rho with deterministic parameters, so factorisation may loop indefinitely although this is extremely improbable. A semiprime N will fail at a rate of 0.5^x where x is the period of a xorshift seeded with N, random computer errors and hardware failure are far more likely.

The factors are output in the form of an array of prime factors and an array of powers with the length.

This library primarily exists as a system library, so fancy formatting is ignored.


lib.rs:

Machine-factor is a relatively fast library for factoring integers up to 2^128. Most integers can be factored in less than
60 seconds (on i5-5300U). Machine-factor can be used in const contexts, however this is will often exceed the allowed time.

Dependencies

~1.5MB
~17K SLoC