Browse Source

10001st prime

Adel Qalieh 13 years ago
parent
commit
5d0d4e2ef1
1 changed files with 17 additions and 0 deletions
  1. 17 0
      7.py

+ 17 - 0
7.py

@@ -0,0 +1,17 @@
+from math import sqrt
+
+def prime(n):
+	for i in range(2, int(sqrt(n) + 1)):
+		if n % i == 0:
+			return False
+	return True
+
+primes = []
+i = 1
+
+while len(primes) < 10001:
+	i += 1
+	if prime(i):
+		primes.append(i)
+
+print i