input = [1245, 4198] res = {str(i):0 for i in range(10)} print(res) for i in range(input[0], input[1]+1): s = str(i) while len(s) > 1: p = 1 for c in s: p = p *int(c) s = str(p) res[s] += 1 for i in res: if i != "0": print(res[i], end=", ")