Change calculates only largest palindromes but returns correct answer