Commit Graph

12 Commits

Author SHA1 Message Date
ddidderr 8222199a7d feat: accept search limit as CLI argument
Allow users to override the default HCN search limit by passing one optional
positive integer argument. Bad input now exits with status 2 and prints a clear
message instead of silently using a fixed range.

Keep the existing one-billion default when no argument is provided, so current
usage remains unchanged.

Test Plan:
- cargo clippy
- cargo clippy --benches
- cargo clippy --tests
- cargo test

Refs: N/A
2026-04-26 13:48:19 +02:00
ddidderr e36cecd2d3 perf: generate HCN records from exponent vectors
Replace the range scan and trial division with a search over prime exponent
vectors. Highly composite records only need candidates whose exponents are
non-increasing across ascending primes, so the program can compute divisor
counts directly while pruning branches above the search limit.

Remove the sieve module because the new search no longer factors each number.
This makes the current one-billion limit finish in microseconds after startup
instead of scanning hundreds of millions of inputs.

Test Plan:
- cargo clippy
- cargo clippy --benches
- cargo clippy --tests
- cargo test

Refs: N/A
2026-04-26 13:47:44 +02:00
ddidderr ca93c145bb clippy: fixes 2026-04-26 13:33:25 +02:00
ddidderr 0208637dd0 chore: update edition from 2021 to 2024 2026-04-26 13:33:03 +02:00
ddidderr d3615307d6 [release] hcn v1.0.0 v1.0.0 2024-09-12 20:25:22 +02:00
ddidderr c31d2fda26 [clippy] stricter lints 2024-09-12 20:14:55 +02:00
ddidderr 1a7e57404e [code] small improvements
* readability: changing variable names/adding variables for clarity
* initialize primes Vec with reasonable space to reduce allocations
* return type of find_next_prime more idiomatic (Option)
* avoid overflow by using checked_mul
2024-02-09 22:38:11 +01:00
ddidderr 2005b7d5ca [clippy] u64 -> f64 conversion is precision loss 2023-12-09 18:26:59 +01:00
ddidderr 24cf088011 [feature] single thread code to calculate hcns using prime factorization 2023-12-07 18:38:36 +01:00
ddidderr 2f6449a25a [fix] prime sieve was missing the number 2 2023-12-07 18:37:42 +01:00
ddidderr 4c56ab2779 [feature] get primes fast with sieve of Eratosthenes 2023-12-02 09:20:20 +01:00
ddidderr 3434c9d4f6 hcn: highly composite number
A tool to find highly composite numbers fast.
2023-12-02 09:19:34 +01:00