Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Numbers Factory by michal123
def checkio(number):
dzielnik = 9
new_dig = ''
while dzielnik>1:
if number%dzielnik==0:
number = number/dzielnik
new_dig=str(dzielnik)+new_dig
else:
dzielnik-=1
if new_dig == '':
return 0
elif number>1:
return 0
else:
return int(new_dig)
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. 29, 2018