from sympy.ntheory import factorint factorint(10**20+1) → {73: 1, 5964848081: 1, 1676321: 1, 137: 1}