 # euler

git clone git://git.codymlewis.com/euler.git
Log | Files | Refs

```commit 7540de69aeabfe021c1b0a6de842562f1eacb246
parent 12c7e99ca86cb0c4528fdec95ad4666bed36bac7
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Sun, 18 Nov 2018 15:28:28 +1100

Solution to problem 7

Diffstat:
ASeven.py | 32++++++++++++++++++++++++++++++++
```
```1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/Seven.py b/Seven.py
@@ -0,0 +1,32 @@
+import math
+'''
+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?
+'''
+
+
+def prime(n):
+    # could cheat with SymPy, but that is not fun.
+    i = 2
+    prime_count = 0
+    while True:
+        if is_prime(i):
+            prime_count += 1
+        if prime_count == n:
+            return i
+        i += 1
+
+
+def is_prime(n):
+    for i in range(2, int(math.ceil(math.sqrt(n)))):
+        if (n % i) == 0:
+            return False
+    return True
+
+
+if __name__ == "__main__":
+    LIMIT = 10_001
+    print("Started finding number...")
+    print(f"The {LIMIT}th prime is {prime(LIMIT)}")
```