1 from math import sqrt
2
3 def is_prim(n):
4 if n < 2:
5 return False
6 for i in range(2, int(sqrt(n)) + 1):
7 if n % i == 0:
8 return False
9 return True
10
11 def get_prim(n):
12 if n < 1:
13 return None
14 x = 1
15 r = 3
16 ret = 2
17 while x < n:
18 if is_prim(r) == True:
19 x = x + 1
20 ret = r
21 r = r + 1
22 return ret
23
24 n = int(input("Input n: "))
25 print(get_prim(n))
26
posted on 2013-05-14 22:25
unixfy 阅读(884)
评论(0) 编辑 收藏 引用