Beakjoon&프로그래머스/파이썬
[백준/파이썬] 1747번 소수&팰린드롬
현장
2022. 5. 3. 20:50
-Code
m = 1000001
sieve = [False, False] + [True] * (m - 1)
for i in range(2, int(m ** 0.5) + 1):
if sieve[i]:
for j in range(i * 2, m, i):
sieve[j] = False
n = int(input())
result = 0
for i in range(n, m):
if sieve[i] and str(i) == str(i)[::-1]:
result = i
break
print(result if result != 0 else 1003001)
범위와 값이 1000000일때의 값을 설정을 해주지 않아서 많이 틀렸습니다.