[백준] 4948번 : 베르트랑 공준 - Python(파이썬)

강재원·2022년 10월 21일
0

[코딩테스트] Python

목록 보기
139/200



https://www.acmicpc.net/problem/4948

import math
while 1:
    n=int(input())
    if n==0: break
    count=0
    cnt=0
    for i in range(n+1,2*n+1):
        for j in range(2,int(i**(1/2))+1):
            if i%j==0:
                cnt=1
                break
        if cnt==0: count+=1
        cnt=0
    print(count)
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글