Share my Python Solution


  • 0
    A

    Open for any suggestions and improvements, thank you!

    j, res = 0, 0
    for div in range(9, 1, -1):
        if a == 1:
           break
        while a != 1 and a % div == 0:
           a = a / div
           res = res + div * 10**j
           j += 1
                    
    if a > 1 or res > 2**31 - 1:
        return 0
    else:
        return res
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.