for p in prime_iter:
if threshold < p:
# If p is large, find the power root p directly without `iroot`.
while True:
b = pow(2, logn / p)
rb = int(b + 0.5)
if abs(rb - b) < 0.01 and rb**p == n:
n = rb
multi *= p
logn = math.log2(n)
else:
break
else:
while True:
m, _exact = iroot(n, p)
if _exact: