Last active
October 10, 2018 13:00
-
-
Save lion137/70bd2ee8b0652ebc8e39c9582f4904c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Infinite primes generator and quantum article check: | |
| # https://www.quantamagazine.org/mathematicians-discover-prime-conspiracy-20160313/ | |
| from tests import miller_rabin | |
| def primes_generator(): | |
| i = 2 | |
| while True: | |
| if miller_rabin(i): | |
| yield i | |
| i += 1 | |
| if __name__ == '__main__': | |
| primes = primes_generator() | |
| nine_ends_pair = 0 | |
| one_ends_pair = 0 | |
| nines = 0 | |
| tmp = None | |
| primes_length = 0 | |
| for x in primes: | |
| primes_length += 1 | |
| if primes_length > 10 ** 8: break | |
| if not tmp: | |
| tmp = x % 10 | |
| if tmp == 9: nines += 1 | |
| elif tmp: | |
| a, b = tmp, x % 10 | |
| if tmp == 9: nines += 1 | |
| if a == 9 and b == 9: nine_ends_pair += 1 | |
| if a == 9 and b == 1: one_ends_pair += 1 | |
| tmp = x % 10 | |
| print(nine_ends_pair, one_ends_pair, nines, primes_length) ## -> Replicates outcomes: 4622916, 7991431, 25000026, 100000001 | |
| ## For 9 and 1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment