math calculations

gcd and lcm functions, compact isPalindrome function