We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #4: Largest palindrome product
Project Euler #4: Largest palindrome product
Sort by
recency
|
301 Discussions
|
Please Login in order to post a comment
C++ code
def is_palindrome(n): return str(n) == str(n)[::-1] def checker(k): for i in range(999, 99, -1):
if k % i == 0 and 100 <= k // i <= 999: return True return False
def main(): t = int(input()) for _ in range(t): n = int(input()) for i in range(n - 1, 101101 - 1, -1): if is_palindrome(i) and checker(i): print(i) break
if name == "main": main()
}
public class Solution {
// Pattern pttr = Pattern.compile("\d\d\d\d\d\d"); // Matcher m = pttr.matcher(String.valueOf()); // if (!m.matches()) { // // continue; // // } else { // // smallest = l; // //System.out.println(i); // //System.out.println(temp/i); // // // }
}