Created
June 4, 2013 16:10
-
-
Save furushchev/5707209 to your computer and use it in GitHub Desktop.
Project Euler Problem 12
This file contains 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
#!/usr/bin/env python | |
import math as m | |
def check_div(num): | |
ret = 0 | |
sq = m.sqrt(num) | |
for i in range(1, int(round(sq))+1): | |
if num % i == 0: | |
ret += 1 | |
ret *= 2 | |
if sq * sq == num: | |
ret += 1 | |
return ret | |
def eval(num): | |
tri = (sum(range(1,x+1)) for x in range(10000000)) | |
tri.next() | |
while True: | |
val = tri.next() | |
if check_div(val) > num: | |
break | |
return val | |
if __name__ == '__main__': | |
print eval(500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment