diff --git a/indivisible.1 b/indivisible.1 index 16648d9..63c1b11 100644 --- a/indivisible.1 +++ b/indivisible.1 @@ -19,6 +19,9 @@ Import prime numbers from \fIFILE\fR \fB\-t\fR, \fB\-\-test\fR Test if n is a prime instead of generation .TP +\fB\-s\fR, \fB\-\-sieve\fR +Set a custom sieve size +.TP \fB\-v\fR, \fB\-\-verbose\fR Print all found primes .TP diff --git a/src/main.rs b/src/main.rs index ea05ab1..cca82a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,12 +35,12 @@ struct Opt { test:bool, #[structopt(help = "Max of the prime to generate or number to test for primality")] num:usize, + #[structopt(short, long, default_value = "1000", help = "Set a custom sieve size")] + sieve:usize, //#[structopt(short, long, name = "n", default_value = "1", help = "Number of threads to spawn")] //jobs:u64, } -const SEGMENT_SIZE:usize = 0x100000000; - fn main() { let opts = Opt::from_args(); let mut prime_list = Vec::new(); @@ -69,8 +69,8 @@ fn main() { (*prime_list.last().unwrap() + 1) as usize }; while start < opts.num { - let end = if start + SEGMENT_SIZE < opts.num { - start + SEGMENT_SIZE + let end = if start + opts.sieve < opts.num { + start + opts.sieve } else { opts.num + 1 }; @@ -83,7 +83,7 @@ fn main() { } prime_list.append(&mut new_primes); - start += SEGMENT_SIZE; + start += opts.sieve; } if opts.test {