From 6069f459d9d6b81bfc437317cb21ff1d634ae5cd Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Wed, 20 Nov 2024 10:39:43 +0000 Subject: [PATCH] solutions: 7 --- 10001st_prime.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 10001st_prime.rs diff --git a/10001st_prime.rs b/10001st_prime.rs new file mode 100644 index 0000000..021140d --- /dev/null +++ b/10001st_prime.rs @@ -0,0 +1,23 @@ +fn is_prime(num: u64) -> bool { + let prime: bool = true; + for i in 2..=((num as f64).sqrt() as u64) { + if num % i == 0 { + return false; + } + } + prime +} + +fn main() { + let mut primes: Vec = vec![]; + let mut increment: u64 = 2; + + while primes.len() < 10001 { + if is_prime(increment) { + primes.push(increment); + } + increment += 1; + } + + println!("{:?}", primes); +}