diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-08-11 22:41:34 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-08-11 22:41:34 +0200 |
| commit | 1879caa1dd80cb11dd62403663917ad4bf7cc68e (patch) | |
| tree | ea41c6dd83a9f9bbfe0a891237674342de92d533 /python/007-10001st_prime.py | |
| parent | 6b16d921543a62d880171791d39bcc58560785fa (diff) | |
| download | project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.gz project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.bz2 project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.zip | |
rename all file with 3 zero padding
Diffstat (limited to 'python/007-10001st_prime.py')
| -rw-r--r-- | python/007-10001st_prime.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/python/007-10001st_prime.py b/python/007-10001st_prime.py new file mode 100644 index 0000000..19793f3 --- /dev/null +++ b/python/007-10001st_prime.py @@ -0,0 +1,26 @@ +import math + + +prime_numbers = [] + +num = 2 +end = False +while not end: + num_sqrt = math.ceil(math.sqrt(num)) + + is_prime = True + for prime_num in prime_numbers: + if prime_num < num_sqrt + 1: + if num % prime_num == 0: + is_prime = False + else: + break + + if is_prime: + prime_numbers.append(num) + num += 1 + + if len(prime_numbers) == 10001: + break + +print(prime_numbers[-1]) |
