# Recover the power from the prime power

It seems that many people would like to have this, so it's now a sequel to this challenge!

Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number.

Task: Given a prime power pn > 1, return the power n.

Testcases:

input output
9     2
16    4
343   3
2687  1
59049 10


Scoring: This is . Shortest answer in bytes wins.

• Note: This challenge might be trivial in some golfing languages, but it's not so trivial for some mainstream languages, as well as the language of June 2018, QBasic. – Erik the Outgolfer Jun 20 '18 at 23:55
• Can we output True instead of 1? Alternatively, float instead of ints? – Jo King Jun 21 '18 at 0:33
• @JoKing yes, yes. – Leaky Nun Jun 21 '18 at 0:34
• @EriktheOutgolfer Challenge accepted :D – DLosc Jun 22 '18 at 4:46

# Factor + math.primes.factors, 18 bytes

[ factors length ]


Try it online!

# Excel, 34 bytes

=SUM((MOD(A1,SEQUENCE(A1-1))=0)*1)


Counts the factors. Works up to 2 ^ 20.

# Gaia, 2 bytes

ḍl


Try it online!

# JavaScript (ES6), 37 bytes

f=(n,k=2)=>n%k?n>1&&f(n,k+1):1+f(n/k)


Try it online!

# Perl 6, 36 bytes

{round .log/log (2..*).first: $_%%*}  Looks for the first factor (2..*).first:$_%%*, then from there calculates the approximate value (logs won't get it exact) and rounds it.

Try it online!

# Pari/GP, 8 bytes

bigomega


Try it online!

bigomega(x): number of prime divisors of x, counted with multiplicity.

# Pari/GP, 14 bytes

n->numdiv(n)-1


Try it online!

# Racket, 31 bytes

(car(cdr(perfect-power(read))))


Try it online!

# Perl 6, 18 bytes

{+grep($_%%*,^$_)}


Try it online!

Anonymous code block that gets a list of factors and coerces it to a number.