import math
from math import *
def p12e(int1):
# i and tri are for advancing the triangular number
i = 1
tri = 1
factors = 1
# loop until there are more than int1 factors
while factors <= int1:
factors = 1
##########
# Calculate the number of factors that tri has.
prime = 1
temp = tri
# STOP WHEN PRIME IS BIGGER THAN TRIANGLE:
t = 1
while temp % 2 == 0:
temp = temp / 2
t += 1
factors *= t
t = 1
while temp % 3 == 0:
temp = temp / 3
t += 1
factors *= t
##########
while prime <= tri:
prime = prime + 2
# DIVIDE AS MANY TIMES AS POSSIBLE
t = 1
while temp % prime == 0:
temp = temp / prime
t += 1
factors *= t
##########
# keep together
i += 1
tri += i
# when done, what is the triangle number that meets requirements?
return tri - i