Skip to content

Instantly share code, notes, and snippets.

@konstruktoid
Last active March 23, 2020 08:34
Show Gist options
  • Save konstruktoid/0a821211aecdaa29db2dc241724fd51d to your computer and use it in GitHub Desktop.
Save konstruktoid/0a821211aecdaa29db2dc241724fd51d to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# https://oeis.org/A232449
# Belphegor's Prime: n = 13
def belph(n):
belph = (10 ** (n + 3) + (2 * 3 ** 2 * 37)) * 10 ** (n + 1) + 1
return belph
# https://www.daniweb.com/programming/software-development/code/216880/check-if-a-number-is-a-prime-number-python
def is_prime(n):
# make sure n is a positive integer
n = abs(int(n))
# 0 and 1 are not primes
if n < 2:
return False
# 2 is the only even prime number
if n == 2:
return True
# all other even numbers are not primes
if not n & 1:
return False
# range starts with 3 and only needs to go up the squareroot of n
# for all odd numbers
for x in range(3, int(n ** 0.5) + 1, 2):
if n % x == 0:
return False
return True
if __name__ == "__main__":
a = [1, 2, 3, 5, 8, 13]
for n in a:
p = belph(n)
if p == 1000000000000066600000000000001:
z = "%s equals to %s and is Belphegor's prime" % (n, p)
print(z)
print(is_prime(p))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment