From cd8e40d2caaf287ae48e47496d4d869fac5074f2 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Wed, 20 Nov 2024 08:36:13 +0000 Subject: [PATCH] solutions: 4 --- largest_palindrome_product.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 largest_palindrome_product.rs diff --git a/largest_palindrome_product.rs b/largest_palindrome_product.rs new file mode 100644 index 0000000..e5cb3d0 --- /dev/null +++ b/largest_palindrome_product.rs @@ -0,0 +1,16 @@ +fn main() { + let mut product: i64 = 0; + + for i in 1..=999 { + for j in 1..=999 { + let product_string: String = format!("{:?}", i*j); + let reversed_string = product_string.chars().rev().collect::(); + + if i*j > product && reversed_string == product_string { + product = i*j; + } + } + } + + println!("{}", product); +}