Browse Source

058 with bugs

master
Coin de Gamma 10 months ago
parent
commit
68c4dd93e8
  1. 30
      058/main.rs

30
058/main.rs

@ -1,9 +1,11 @@
use std::collections::HashSet;
const UP: usize = 100;
// from../ 027/main.rs
fn er() -> HashSet<u32> {
fn er() -> HashSet<usize> {
let mut nums = Vec::new();
let size = 600_000_000;
let size = UP;
for _n in 0..size+1 { nums.push(true); }
let mut p = 1;
loop {
@ -22,7 +24,7 @@ fn er() -> HashSet<u32> {
}
let mut res = HashSet::new();
for i in 2..size {
if nums[i] { res.insert(i as u32); }
if nums[i] { res.insert(i); }
}
return res;
}
@ -43,7 +45,7 @@ impl Steps {
};
}
fn next(&mut self, n: u32) -> Option<u32> {
fn next(&mut self, n: usize) -> Option<usize> {
if self.k > self.l {
self.k = 1;
self.s += 1;
@ -72,14 +74,15 @@ impl Steps {
fn main() {
let mut st = Steps::new();
println!("er begin");
let ps = er();
println!("er");
return;
println!("er end");
//return;
let mut sq = 1;
let mut corner_count = 0;
let mut p_count = 0;
for n in 1..900_000_000 {
if n > sq * sq {
let mut corner_count = 1;
let mut p_count = 1;
for n in 1..UP {
if n >= sq * sq {
sq += 1;
}
match st.next(n) {
@ -89,10 +92,9 @@ fn main() {
if is_prime {
p_count += 1;
}
let ratio = 100.0 * (p_count as f64) /(corner_count as f64);
println!("{}.{} \t({})\t[{}]", k, is_prime, sq, ratio);
if ratio < 10.0 {
println!("{} {} {} {}", n, sq, corner_count, p_count);
if ((p_count as f64) * 100f64 as f64) / (corner_count as f64) < 60f64 {
println!("!!{}", sq);
break;
}
},

Loading…
Cancel
Save