Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Numbers Factory by Sim0000
def all_factor(data, p0, result):
global factor_list
if data == 1:
factor_list.append(result)
return
for p in range(p0, 10):
if data % p == 0:
all_factor(data // p, p, result * 10 + p)
return
def checkio(data):
global factor_list
factor_list = []
all_factor(data, 2, 0)
if len(factor_list) == 0:
return 0
return min(factor_list)
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
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(5) == 5, "5th example"
Feb. 15, 2014
Comments: