Project Euler Problem7
10001st prime
Problem 7
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?
The solve this one, we should learn how to check whether a number is prime, can also refer to Problem 3
The whole code is as follows:
1 import math 2 def isPrime(data): 3 i = 2 4 while i <= math.sqrt(data): 5 if data%i == 0: 6 return False 7 i += 1 8 return True 9 10 count = 10001 11 i = 2 12 while count > 0: 13 if isPrime(i): 14 count -= 1 15 i += 1 16 print(i-1)
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步