Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import time
- with open('prime_numbers.txt', 'w') as file:
- timeBeforeBench = time()
- for num in range(2, 5001):
- i = 2
- count = 0
- while i < num:
- if num % i == 0:
- count += 1
- i += 1
- if count == 0:
- print(num, file=file)
- timeAfterBench = str(round(time() - timeBeforeBench, 2))
- print(timeAfterBench + 's', file=file)
- print('done. ' + timeAfterBench + 's')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement