Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Numbers Factory by nickie
def checkio(n):
if n <= 1: return n
l = ""
for r in "98765432":
while n > 1:
d, m = divmod(n, int(r))
if m != 0: break
n = d
l = r + l
return int(l) if n == 1 else 0
#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"
Nov. 17, 2013
Comments: