slight rewrite of palindrome for efficiency, updated P4 to only save the maxPalindrome (and factors) to reduce computation time