지나가던 개발자
[Python] 백준 24039번(2021은 무엇이 특별할까?) 문제 풀이 본문
import math
def is_prime(n):
if n == 1:
return False
for i in range(2, int(math.sqrt(n))+1):
if n % i == 0:
return False
return True
n = int(input())
i = 2
ans = []
while True:
if is_prime(i):
ans.append(i)
if len(ans) == 2:
if ans[0]*ans[1] > n:
print(ans[0]*ans[1])
break
del ans[0]
if i == 2:
i += 1
continue
i += 2
'PS > Python' 카테고리의 다른 글
[Python] 백준 7568번(덩치) 문제 풀이 (0) | 2022.12.01 |
---|---|
[Python] 백준 14382번(숫자세는 양 (Large)) 문제 풀이 (0) | 2022.11.28 |
[Python] 백준 21920번(서로소 평균) 문제 풀이 (0) | 2022.11.26 |
[Python] 백준 5939번(Race Results) 문제 풀이 (0) | 2022.11.24 |
[Python] 백준 9417번(최대 GCD) 문제 풀이 (0) | 2022.11.23 |
Comments