Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Numbers Factory by csa0127
list1 = [9,8,7,6,5,4,3,2]
def checkio(number):
text = ""
result = number;
while(result != 1):
for num in list1:
if((result / num).is_integer()):
text += str(num)
result = int(result // num)
break;
if(num == 2):
return 0
return int(text[::-1])
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"
Aug. 30, 2018