문제
뒤집은 수가 소수이면 그 수를 출력하는 프로그램을 작성
🔑 KeyPoint!
자연수를 뒤집는 함수와 소수여부를 판단하는 함수를 작성
import sys
sys.stdin = open("1-8 뒤집은 소수/input.txt", "rt")
n = int(input())
a = list(map(int, input().split()))
def reverse(x):
res = 0
while x > 0:
t = x % 10
res = res * 10 + t
x = x // 10
return res
def isPrime(x):
if x == 1:
return False
for i in range(2, x // 2 + 1):
if x % i == 0:
return False
else:
return True
for i in a:
rev = reverse(i)
if isPrime(rev):
print(rev, end=" ")
for i in range(2, x // 2 + 1)
res = res * 10 + (x % 10)