Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from math import sqrt, floor
- # How many primes are 6n +/- 1?
- total: int = 0
- prime: int = 0
- def is_prime(x: int) :
- for y in range(2, floor(sqrt(x) + 1)) :
- if x % y == 0 :
- return False
- return True
- with open('prime_list.txt', 'w') as of :
- for x in range(1, 1000000) :
- for y in -1, 1 :
- z = 6 * x + y
- z1 = is_prime(z)
- total += 1
- prime += 1 if z1 else 0
- #
- print('6({:>10}){:+}={:>11} {} {:>4.15}%'.format(
- x,
- y,
- z,
- ('T' if z1 else 'F'),
- (prime * 100 / total)
- ), file=of)
- input('Done.')
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement