Skip to content

Instantly share code, notes, and snippets.

@furushchev
Created June 4, 2013 16:10
Show Gist options
  • Save furushchev/5707209 to your computer and use it in GitHub Desktop.
Save furushchev/5707209 to your computer and use it in GitHub Desktop.
Project Euler Problem 12
#!/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