def bruteForce(string): permuts = permutations(string) for p in permuts: if isPalindrome(p): return True return False
def LPP(n): palindromes = [] for i in range(10**(n - 1), 10**n): for j in range(10**(n - 1), 10**n): ij = i * j if isPalindrome.isPalindrome(ij): palindromes.append(ij) return max(palindromes)
def main(): result = 1 for i in range(1000): for j in range(1000): multi = i*j if isPalindrome(multi) and multi > result: result = multi print(result)
def test_case_2(self): self.assertEqual(isPalindrome('foobar'), False)
def test_case_1(self): self.assertEqual(isPalindrome('awesome'), False)
def test_case_6(self): self.assertEqual(isPalindrome('aa'), True)
def test_case_6(self): self.assertEqual(isPalindrome(''), False)
def test_case_5(self): self.assertEqual(isPalindrome('amanaplanacanalpanamonium'), False)
def test_case_4(self): self.assertEqual(isPalindrome('amanaplanaccanalpanama'), True)
def test_case_3(self): self.assertEqual(isPalindrome('tacocat'), True)
from isPalindrome import isPalindrome from isPrime import isPrime if __name__ == '__main__': num = int(input('请输入正整数: ')) if (isPalindrome(num) and isPrime(num)): print('%d是回文素数' % num) else: print('%d不是回文素数' % num)