Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
chore: tweak settings for example
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeron committed Mar 29, 2020
1 parent 12549b0 commit 4a25188
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/strange_prime_factorization/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
//!
//! 1. You can execute this example from the command line, to find "nice" prime factorizations of
//! large numbers: start at a big number and it tries to find numbers below that that have
//! nicer and nicer prime factorizations.
//! nicer and nicer prime factorizations:
//!
//! cargo run --release --example strange_prime_factorization -- -- 9007199254740991
//!
//! 2. You can execute benchmarks with `cargo +nightly bench --features bench,benchall --example strange_prime_factorization`.
//! Rust nightly is needed for benchmarks.
//!
#![cfg_attr(feature = "bench", feature(test))]

mod using_bigint;
Expand All @@ -27,9 +30,9 @@ use std::str::FromStr;
use structopt::StructOpt;

#[cfg(feature = "bench")]
const SMALL_PRIME_LIMIT: &str = ONE_HUNDRED_THOUSAND;
const SMALL_PRIME_LIMIT: &str = ONE_MILLION;
#[cfg(feature = "bench")]
const ONE_HUNDRED_THOUSAND: &str = "100000";
const ONE_MILLION: &str = "1000000";

lazy_static! {
pub static ref DEFAULT_TARGET: Int = Int::from_str(&"9007199254740991").unwrap();
Expand Down Expand Up @@ -72,8 +75,9 @@ fn main() -> Result<(), ExitFailure> {
None => println!(" Failed to compute factorization for {}", n),
Some(factors) => {
let quality = unique_elements(&factors);
if quality <= best_quality {
best_quality = quality;
// Only report results that are at most 2 worse than the current best
if quality <= best_quality + 2 {
best_quality = quality.min(best_quality);
println!(
"- {} has {} unique factors: [{}]",
n,
Expand Down

0 comments on commit 4a25188

Please sign in to comment.