solutions: 7

This commit is contained in:
Muhammad Nauman Raza 2024-11-20 10:39:43 +00:00
parent 10a975e978
commit 6069f459d9
Signed by: devraza
GPG key ID: 91EAD6081011574B

23
10001st_prime.rs Normal file
View file

@ -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<u64> = vec![];
let mut increment: u64 = 2;
while primes.len() < 10001 {
if is_prime(increment) {
primes.push(increment);
}
increment += 1;
}
println!("{:?}", primes);
}