Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Numbers Factory by haveno
def checkio(data):
divider = (9, 8, 7, 6, 5, 4, 3, 2) # start from biggest number, because we do not want the largest divisor (e.g. 2*2*2*2*3 instead of 8*6 - which we later convert to 6*8)
factors = []
for x in divider:
while data % x == 0: # run as long as the number is dividable by x (e.g. 3125 -> 625 -> 125 -> 25 -> 5)
factors.append(x)
data //= x
if data == 1: # return only if data has been broken completely and there is no prime left
return int("".join(map(str, sorted(factors)))) # sort list in ascending order, convert each element to string (with map), then join them to one string and convert it to int
return 0 # still a prime factor left, so return 0
April 27, 2014
Comments: