Created
July 24, 2021 07:11
-
-
Save igorvanloo/e4ed831d511951acf8a011d6693756a2 to your computer and use it in GitHub Desktop.
Problem 45
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 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