# 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

# JavaScript (Node.js), 29 bytes

f=(n,k=n)=>--k&&!(n%k)+f(n,k)


Try it online! Note: Stack overflows for larger inputs.

# F#, 91 bytes

let rec d n c v=if v=n then c else d(n/v)(c+1)v
let p n=d n 1(Seq.find(fun x->n%x=0){2..n})


Try it online!

p gets the prime factor. d recursively divides the target value until it's equal to the prime factor and returns the count from that.