#!/usr/bin/env python import time mul = lambda v, r=1: r if v == 0 else mul(v // 10, v % 10 * r) count = lambda v, c=0: (v, c) if v < 10 else count(mul(v), c+1) judge = lambda v, mc, r, c: (c > mc, v, r, max(c, mc)) calc = lambda v, mc: judge(v, mc, *count(v)) if __name__ == "__main__": st = time.time() (v, c) = (0, 0) while True: (f, v, r, c) = calc(v+1, c) if f: tm = time.time() - st print('{}, {}, {} # {} sec'.format(v, r, c, tm)) # EOF