Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Numbers Factory by Bartosz_M
def checkio(number):
#replace this for solution
factors = []
final = ""
iloczyn = 1
help_num = number
for i in range(9, 1, -1):
while help_num % i == 0:
help_num = help_num / i
factors.append(i)
factors = sorted(factors)
for i in factors:
iloczyn *= i
final = final + str(i)
if iloczyn != number or len(factors) == 0:
return 0
return int(final)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(20) == 45, "1st example"
assert checkio(21) == 37, "2nd example"
assert checkio(17) == 0, "3rd example"
assert checkio(33) == 0, "4th example"
assert checkio(3125) == 55555, "5th example"
assert checkio(9973) == 0, "6th example"
Nov. 13, 2016