File: binary-search-iterator.rs

package info (click to toggle)
rust-primal 0.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: sh: 33; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::env;
use std::time::Instant;

fn main() {
    let mut args = env::args();
    let zeros = args
        .nth(1).and_then(|s| s.parse::<f64>().ok().map(|x| x as u32))
        .unwrap_or(10);

    let start = Instant::now();
    let p = primal::Primes::all().find(|p| (p / 2).trailing_zeros() >= zeros).unwrap();
    let time = start.elapsed();

    println!("{} is the first prime with {} zeros, in {:?}",
             p, zeros, time);
}