寻找回文素数python123
时间: 2023-11-24 10:53:32 浏览: 113
python寻找回文素数
以下是寻找回文素数的Python代码:
```python
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5)+1):
if n % i == 0:
return False
return True
def is_palindrome(n):
return str(n) == str(n)[::-1]
n = int(input())
count = 0
i = 2
while count < n:
if is_prime(i) and is_palindrome(i):
print(i, end=' ')
count += 1
i += 1
```
阅读全文