You are viewing a single comment's thread. Return to all comments →
bool isPalindrome(int n) { string fwd(to_string(n)); string rev(to_string(n)); std::reverse(rev.begin(), rev.end()); return (fwd == rev); } void findPalindromeFactors(int n) { int max = 0; for (int i = 100; i < 1000; i++) { for (int j = i; j < 1000; j++) { int prod = i * j; if (prod < n) { if (prod > max && isPalindrome(prod)) { max = prod; } } } } cout << max << endl; }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #4: Largest palindrome product
You are viewing a single comment's thread. Return to all comments →