SHARE
TWEET

Untitled

a guest Jul 18th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn main() {
  2.     let num: usize =  100000;
  3.     let mut prime = vec![1; num+1];
  4.     let limit: usize;
  5.  
  6.     for i in 2..num {
  7.         prime[i] = 1;
  8.     }
  9.     limit = ((num as f64).sqrt() as usize);
  10.  
  11.     for i in 2..limit {
  12.         if prime[i] == 1 {
  13.             for j in i*2..num {
  14.                 if j % i == 0 {
  15.                     prime[j] = 0;
  16.                 }
  17.             }
  18.         }
  19.     }
  20.     for i in 2..num {
  21.         if prime[i] == 1 {
  22.             println!("{}", i);
  23.         }
  24.     }
  25.     println!("\n");
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top