from math import sqrt number=int(input('请输入一个整数:')) def is_prime(num): for rea in range(2,int(sqrt(num)+1)): if num%rea==0: return False return True if num !=1 else False def is_palindrome(num): temp=num total=0 while temp>0: total=total * 10+temp %
Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's only divisors are 1 and itself, and it is greater than 1. For example, 2,3,5,7,11 and 13 are primes. Recall that a number is a palindrome if it reads
//判断给定字符串是否是回文 function isPalindrome(word) { var s = new Stack(); for (var i = 0; i < word.length; i++) { s.push(word[i]); } var rword = ""; while (s.length()>0) { rword +
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写. 说明:本题中,我们将空字符串定义为有效的回文串. 示例 1: 输入: "A man, a plan, a canal: Panama"输出: true示例 2: 输入: "race a car"输出: false class Solution: def isPalindrome(self, s: str) -> bool: s = list(filter(str.isalnum,
class Solution: def isPalindrome(self, x: int) -> bool: a = x if a<0: return False else: num = 0 while(a!=0): temp = a%10 a = a//10 num = num*10+temp if num==x: return True else: return False