def find_consecutive(howmany): latest = [] # factors of the previous consecutive numbers for n in itertools.count(2): facn = factors.factor_count(n).items() if len(facn) != howmany: latest = [] continue latest.append(set(facn)) latest = latest[-howmany:] ## are they distinct? all_factors = functools.reduce(set.union, latest) if len(all_factors) == howmany**2: return n - howmany + 1
def count_divisors(n): fdict = factors.factor_count(n) if not fdict: return 1 return functools.reduce(operator.mul, (c+1 for c in fdict.values()))