With stuff like
for else and no need to check for overflow, coding problems like this is so easy.
def smallestFactorization(self, a): val = '' while a != 1: for i in range(9,1,-1): if not a%i: a /= i val += str(i) break else: return 0 val = int(val[::-1]) return val if val <= 2**31 else 0
@david120 I just get started with Python, and I totally agree. Python makes you focus more on the problem itself instead of the implementation.
The code seems to have an edge case
a = 1 to handle. How about initialize
val = '' if a > 1 else '1'