Algorithm/boj

[파이썬] 1990 소수인팰린드롬

takeU 2022. 9. 25. 13:43
반응형
a, b = map(int, input().split())

def is_prime(x):
    for i in range(2, int(x ** 0.5) + 1):
        if x % i == 0:
            return False
    return True

for i in range(a, b + 1):
    if i in [5, 7, 11]:
        print(i)
    elif len(str(i)) % 2 and str(i) == str(i)[::-1]:
        if is_prime(i):
            print(i)
print(-1)

소수 판정

반응형