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

no-std machine-factor

constant factorisation for machine-size integers

4 releases

new 0.2.3 Apr 17, 2025
0.2.2 Apr 17, 2025
0.2.1 Mar 14, 2025
0.2.0 Jan 29, 2025
0.1.0 Jan 26, 2025

#2050 in Math

Download history 202/week @ 2025-01-25 39/week @ 2025-02-01 3/week @ 2025-02-08 2/week @ 2025-02-15 37/week @ 2025-03-01 112/week @ 2025-03-08 70/week @ 2025-03-15 1/week @ 2025-03-22 119/week @ 2025-04-12

120 downloads per month

CC0 license

16KB
414 lines

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.


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.

Dependencies

~1.5MB
~17K SLoC