FactorForcer is a command-line utility written in Rust that solves a specific factorization problem: finding the unique combination of a fixed number of prime factors that multiply up to a target number (if such a combination exists).
This tool is particularly useful for problems where a target value
Where
The program requires two command-line arguments:
Format:
factorforcer <size> <goal>
| Argument | Description | Constraints |
|---|---|---|
<size> |
The exact number of prime factors required in the solution. | Must be between 1 and 32. |
<goal> |
The target number to be factorized. | Must be large enough to be factorized into the given size. |
Example:
To find all ways that the number 30 can be expressed as a product of 3 prime numbers:
factorforcer 3 30
-
Sieve of Eratosthenes:
Generates all prime numbers up togoalusing a optimizedbitvecarray.
-> (To speed this step up since it takes so long using a default 8 bit bool Vector) -
Recursive Search:
Stack-based Depth-First Search algorithm to find the unique factorization that matches the required size. The search only considers factors in non-decreasing order.
The initialization of the bitvec array for the Sieve of Eratosthenes can be time-consuming when handling very large numbers.
Also its spagetthi code af 🤌 🍝
Updates
This program relies on the external Rust crate bitvec for efficient boolean array management.
-> (used in the Sieve implementation)
To compile, ensure your Cargo.toml includes:
[dependencies]
bitvec = "1.0"This utility was developed because i got a bit to invested in prime factoralisation and represents my very first project written in Rust.
While the code successfully solves the problem, it may not reflect the most idiomatic or highly optimized Rust practices, as it was primarily built as an initial learning experience.
