From 5538ac7515763491c0c7e7b58e82cf24a62c517b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Fri, 26 Feb 2021 18:27:16 +0100 Subject: [PATCH] Optimize the algorithm --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index bfda9e8..3375191 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,14 +8,14 @@ fn main() { // first prime println!("{}", 2); // already have first prime - let mut prime_count = 1; - let mut candidate = 3; + let mut prime_count:u64 = 1; + let mut candidate:u64 = 3; while prime_count < n { - let mut aux = 3; + let mut aux:u64 = 3; let mut is_prime = true; - while aux < candidate / 2 + while aux < (candidate as f64).sqrt() as u64 { if candidate % aux == 0 {