1 struct Pt { 2 v:Vec<u64>, 3 } 4 5 impl Pt { 6 fn new(t:u64) -> Pt { 7 Pt { 8 v:vec![2], 9 } 10 .fill(t) 11 } 12 fn fill(mut self,n:u64) -> Self { 13 let mut i = *self.v.last().unwrap(); 14 while i < n { 15 let mut for_end = true; 16 for j in &self.v { 17 if i%j == 0 { 18 for_end = false; 19 break; 20 } 21 } 22 if for_end { 23 self.v.push(i); 24 } 25 i += 1; 26 } 27 self 28 } 29 }
标签:prime,mut,end,Pt,self,u64,table From: https://www.cnblogs.com/acd407/p/17744065.html