-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem12.py
38 lines (35 loc) · 932 Bytes
/
problem12.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
def getAllPrimes(n):
primes = []
ints = [i for i in range(2, n)]
for index, value in enumerate(ints):
if value == -1:
continue
primes.append(value)
for i in range(index, len(ints), value):
ints[i] = -1
return primes
def getDivisorCount(num, primes):
finalCount = 1
for prime in primes:
if (num%prime != 0):
continue
count = 0
while(num%prime == 0):
count += 1
num = num / prime
finalCount = finalCount * (count + 1)
if (num == 1):
break
return finalCount
index = 1
triangle = 0
primes = getAllPrimes(100000)
print("done with primes")
while(True):
triangle += index
count = getDivisorCount(triangle, primes)
print(triangle, count)
if (count > 500):
print(triangle)
break
index += 1