DEV Community

loading...

Discussion on: Project Euler #4 - Largest Palindrome Product

Collapse
1258632 profile image
by

while there are many explanations, easiest to understand was yours. the only part I struggle to understand is this one "isPalindrome(product) && product > largestPalindrome", can you please explain what it means?

Collapse
farazpatankar profile image
Faraz Patankar

Yes. Let's try reading it step by step:

  1. We first check if the product is a palindrome. Because if it isn't, we don't care about it.
  2. Then, we check if it is greater than our existing largest palindrome because our goal is to find the largest palindrome.
  3. If both those conditions are true, the product being a palindrome and it being larger than our existing largest palindrome, we set that as our largest palindrome.

Hope that helps, let me know if you still have questions!

Thread Thread
1258632 profile image
by

Thank you, Faraz, I didn't know it was possible to use several conditional operators in one single line of code