@@ -384,23 +384,21 @@ julia> radical(2*2*3)
384384"""
385385radical (n) = prod (factor (Set, n))
386386
387- function primepowerfactor! (n:: T , h:: AbstractDict{K,Int} ) where {T<: Integer ,K<: Integer }
388- r = ceil (Int, inv (log (n, Primes. PRIMES[end ])))+ 1
389- root = inthroot (n, r)
390- while r >= 2
391- if root^ r == n && isprime (root)
392- h[root] = get (h, root, 0 ) + r
393- return true
387+ function factorpower! (n:: Integer , h:: AbstractDict{K,Int} )
388+ if ispower (n)
389+ exponent = find_exponent (n)
390+ root = iroot (n, exponent)
391+ for (p,freq) in factor (root)
392+ h[p] += freq * exponent
394393 end
395- r -= 1
396- root = inthroot (n, r)
394+ return true
397395 end
398396 return false
399397end
400398
401399function lenstrafactors! (n:: T , h:: AbstractDict{K,Int} ) where {T<: Integer ,K<: Integer }
402400 isprime (n) && (h[n] = get (h, n, 0 )+ 1 ; return h)
403- primepowerfactor ! (n:: T , h) && return h
401+ factorpower ! (n, h) && return h
404402 # bounds and runs per bound taken from
405403 # https://www.rieselprime.de/ziki/Elliptic_curve_method
406404 B1s = Int[2e3 , 11e3 , 5e4 , 25e4 , 1e6 , 3e6 , 11e6 ,
@@ -414,7 +412,7 @@ function lenstrafactors!(n::T, h::AbstractDict{K,Int}) where{T<:Integer,K<:Integ
414412 if res != 1
415413 isprime (res) ? h[res] = get (h, res, 0 ) + 1 : lenstrafactors! (res, h)
416414 n = div (n,res)
417- primepowerfactor ! (n:: T , h) && return h
415+ factorpower ! (n, h) && return h
418416 isprime (n) && (h[n] = get (h, n, 0 ) + 1 ; return h)
419417 end
420418 end
0 commit comments