Skip to content

Instantly share code, notes, and snippets.

@M4cs
Created January 23, 2020 21:11
Show Gist options
  • Save M4cs/b30f43268cee5c78a82e8f7d57e6dcf0 to your computer and use it in GitHub Desktop.
Save M4cs/b30f43268cee5c78a82e8f7d57e6dcf0 to your computer and use it in GitHub Desktop.
Outputs Prime Glitch Numbers (ex. 101, 555555555555555585555555, 999999999....999998999999....9999)
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