Last active
August 31, 2015 17:44
-
-
Save anirudhjayaraman/72f9d98fdd269e8da88d to your computer and use it in GitHub Desktop.
Non Meaty Part of Project Euler Problem 12
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
# First Step | |
# First number 'check' to have 500 divisors | |
check = 2**4 * 3**4 * 5**4 * 7 * 11 | |
# Second Step | |
# Starting from 'check', iterate sequentially checking for the next 'triangle' number | |
while not isTriangleNumber(check): | |
check += 1 | |
# Third and Fourth Steps | |
# Calculate the last term of the series ('seriesLastTerm') that adds up to the newly calculated triangle number 'check' | |
seriesLastTerm = lastTerm(check) | |
# Iterate over triangle numbers checking for divisors > 500 | |
while divisors(check) <= 500: | |
# add the next term to check to get the next triangle number | |
check += (seriesLastTerm + 1) | |
seriesLastTerm += 1 | |
print check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment