Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created July 24, 2021 07:11
Show Gist options
  • Select an option

  • Save igorvanloo/e4ed831d511951acf8a011d6693756a2 to your computer and use it in GitHub Desktop.

Select an option

Save igorvanloo/e4ed831d511951acf8a011d6693756a2 to your computer and use it in GitHub Desktop.
Problem 45
def is_pentagonal(x):
#Take the inverse function to test whether or not a number is pentagonal
if (1+(24*x+1)**0.5) % 6 == 0:
return True
return False
def is_hexagonal(x):
#Take the inverse function to test whether or not a number is hexagonal
if (1+(8*x+1)**0.5) % 4 == 0:
return True
return False
def compute():
i = 286
while True:
a = (i/2)*(i+1)
if is_pentagonal(a) == True and is_hexagonal(a) == True:
print(i)
return a
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment