파이썬_실전 프로젝트

프로젝트 오일러 7번문제 - 10001번째 소수

10001 번째 소수를 찾는 문제입니다.

 

10001st prime

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?


 

3번 문제에서 만든 코드를 가지고 쉽게 해결할수 있습니다.

카운트를 하면서, 10001번째가 되면 종료해주면 됩니다.

from sympy import isprime

i=1;primeCount=0
while True:
    if isprime(i):
        primeCount+=1
    if primeCount==10001:
        break
    i+=1
print(i)

sympy 모듈을 설치안하신분들은 pip install sympy 명령으로 설치하시고,

모듈없이 해결하실려면 3번문제 풀이 참조하세요.

댓글

댓글 본문
버전 관리
nomadlife
현재 버전
선택 버전
graphittie 자세히 보기