Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # 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?
- primes_list = [2]
- current_number = 3
- primes_number = 1
- while primes_number <= 10001:
- for i in primes_list:
- if current_number % i == 0:
- break
- else:
- primes_list.append(current_number)
- primes_number += 1
- output = current_number
- current_number += 1
- print(output)
- # 104743
- # 10004 function calls in 12.344 seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement