Created
December 9, 2011 17:36
-
-
Save jakedobkin/1452516 to your computer and use it in GitHub Desktop.
Euler 45 in Python
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
| # we'll store numbers in two sets and keep going until we get a match | |
| i = 286 | |
| found = False | |
| p = set() | |
| h = set() | |
| while found == False: | |
| hex = (i*(2*i-1)) | |
| h.add(hex) | |
| pent = (i*(3*i-1))/2 | |
| p.add(pent) | |
| tri = (i*(i+1))/2 | |
| if tri in h and tri in p: | |
| print i,tri, "found!" | |
| found = True | |
| i = i + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment