You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
627 B

2 years ago
fn is_polindrome(n: i32) -> bool {
let s = n.to_string();
for (p, q) in s.chars().zip(s.chars().rev()) {
if q != p { return false; }
}
return true;
}
fn main() {
let n = 999;
let mut best_i = 1;
let mut best_j = 1;
let mut best_poli = 1;
for i in 100..=n {
for j in 100..=n {
let m = i * j;
if is_polindrome(m) {
if m > best_poli {
best_poli = m;
best_i = i;
best_j = j;
}
}
}
}
println!("{}*{}={}", best_i, best_j, best_poli);
}