Created
January 23, 2020 21:11
-
-
Save M4cs/b30f43268cee5c78a82e8f7d57e6dcf0 to your computer and use it in GitHub Desktop.
Outputs Prime Glitch Numbers (ex. 101, 555555555555555585555555, 999999999....999998999999....9999)
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
def uniqnum(num): | |
unique_set = {} | |
for num in str(num): | |
if unique_set.get(num): | |
unique_set[num] += 1 | |
else: | |
unique_set[num] = 1 | |
return unique_set | |
def isPrime(n) : | |
# Corner cases | |
if (n <= 1) : | |
return False | |
if (n <= 3) : | |
return True | |
# This is checked so that we can skip | |
# middle five numbers in below loop | |
if (n % 2 == 0 or n % 3 == 0) : | |
return False | |
i = 5 | |
while(i * i <= n) : | |
if (n % i == 0 or n % (i + 2) == 0) : | |
return False | |
i = i + 6 | |
return True | |
count = 0 | |
while True: | |
uniq_set = uniqnum(count) | |
if len(uniq_set) == 2: | |
if list(uniq_set.values())[0] >= 2 and list(uniq_set.values())[1] == 1: | |
if isPrime(count): | |
print(count) | |
if list(uniq_set.values())[1] >= 2 and list(uniq_set.values())[0] == 1: | |
if isPrime(count): | |
print(count) | |
count += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment