From 17ee0199493bfe0b548ad751af3a5c63990b91d7 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Wed, 28 Aug 2024 22:08:10 -0500 Subject: [PATCH] Partial revert 'Optimize p37' --- rust/src/p0037.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rust/src/p0037.rs b/rust/src/p0037.rs index de6cb40b..b0bcf74d 100644 --- a/rust/src/p0037.rs +++ b/rust/src/p0037.rs @@ -25,7 +25,7 @@ pub fn p0037() -> Answer { if count == 11 { break; } - if p < 10 { + else if p < 10 { continue; } let mut left = p; @@ -37,7 +37,11 @@ pub fn p0037() -> Answer { continue; } while is_prime(left) { - left %= 10u64.pow(left.ilog10()); + let mut x = 10; + while x < left { + x *= 10; + } + left %= x / 10; } if left != 0 { continue;