Q:
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?
A:
import math
import time
t1 = time.time()
def getNum(n):
#for i in range(2,int(n/2)):
for i in range(2,int(math.sqrt(n))+1):
if n % i == 0:
return 0
return n
count = 2
i = 5
while count < 100001:
if getNum(i):
count += 1
i += 2
print "The 10001st prime number is %d" %(i - 2)
t2 = time.time()
print "time used: %s" %(t2 - t1)
分享到:
相关推荐
数论 The Book of Prime Number Records.pdf 数论 The Book of Prime Number Records.pdf
VHDL 代码,用于查找一个数列的素数搜寻器。
Using this program you can find out the prime numbers between 1 to 100, 100 to 999 etc. You just need to input the range, for e.g. if you want the prime numbers 100 to 999 then enter numbers 100 and ...
A program to find out all prime number.
PrimeNumber 素数生成器 V7.0.0.0 18.7 KB 可快速生成指定范围内的所有素数,并可格式化输出;还可对单个自然数快速因数分解。 HugeCalc V6.x 以上版本现已提供该程序相应导出接口,欢迎使用。 若借助算法库 ...
多功能文件管理器旗舰版 Total.Commander.Ultima.Prime8.2
Finding the prime numbers in range.
pyramid of prime that order by the long of the prime number
PrimeNumber.exe
primenumber找质数代码
任何一个偶数都等于二个素数之差,徐万东,,本文构筑了奇数差式堆垒,并利用奇合数对奇数差式堆垒进行二维筛选,剩下的是二个奇素数之差式。然后,我们利用第二数学归纳法证
PrimeNumber2.java
这个程序是教大家如何编写一定数量素数的程序,当然如果想编写一定数量的素数 要 加上 import java.until.*; 加入输入语句 输入 范围就可以了
prime finding it is realy good for finding primes that algorithm finds the primes O(n)
输出给定数值范围内的所有素数。 使用链表保存数据,动态内存分配,并采用递归思想搜索
Generate prime numbers(min, max] in order. Version: 4, 0, 0, 0 Last Modified: 2004-12-08
C program to check if a number is prime or not
The interface for a Multi-Prime RSA private key.
This document will help you to various experiments related to serial communication Such as 1. Transmitting character/...There is 2 UART’s present in the LPC2148 Prime board • UART0 • UART1