mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-11 00:59:49 +00:00
Create sol2.py
This commit is contained in:
parent
c3b8c51822
commit
e5f130c1f0
8
project_euler/problem_12/sol2.py
Normal file
8
project_euler/problem_12/sol2.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
def triangle_number_generator():
|
||||||
|
for n in range(1,1000000):
|
||||||
|
yield n*(n+1)//2
|
||||||
|
|
||||||
|
def count_divisors(n):
|
||||||
|
return sum([2 for i in range(1,int(n**0.5)+1) if n%i==0 and i*i != n])
|
||||||
|
|
||||||
|
print(next(i for i in triangle_number_generator() if count_divisors(i) > 500))
|
Loading…
x
Reference in New Issue
Block a user