-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem 12.py
45 lines (37 loc) · 1.04 KB
/
problem 12.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from math import *
candidates = []
"""def highlyDivisibleTriangleNumber():
a = 1
for i in range(2,200000):
a += i
if a >= 62370000:
candidates.append(a)"""
"""def highlyDivisibleTriangle2():
for n in range(20000000):
formula = n * (n + 1) / 2
if len(str(formula)) >= 8 and type(formula) == int:
candidates.append(formula)"""
"""def tests():
for item in candidates:
factors = []
for j in range(1,item+1):
if item % == 0:
factors.append(j)
if len(factors) >= 500:
return item"""
def numbers(length):
for a in range(length):
number = a*(a+1)/2
if number >= 62370000:
candidates.append(number)
def factors(n):
return len(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(sqrt(n)) + 1) if n % i == 0))))
def final(listOfCandidates):
for i in listOfCandidates:
if factors(i) >= 500:
return i
#highlyDivisibleTriangle2()
#print(candidates)
numbers(100000)
#print(candidates)
print(final(candidates))