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); +}