Integer Logarithm

Mathematica, 47 45 43 29 bytes SBCS


You can try it online!

Thanks to @J42161217 for saving me a total of 16 bytes!!

Python 3, 103 101 97 bytes

Saved 2 bytes thanks to Kevin Cruijssen!!!
Saved 4 bytes thanks to Value Ink!!!

from math import*
def f(a,b):
 return -1if a**n-b**m else l

Try it online!

Charcoal, 88 82 bytes


Try it online! Link is to verbose version of code. Takes input as a list in [value, base] order and outputs numerator and denominator. Edit: Saved 6 bytes by simplifying my check for exclusive factors. Explanation:


Factorise both numbers by trial division.


Collect the factors from both inputs, in case some factors are only present in one of them.


Divide the multiplicity of each factor in both the base and the value by their GCD.


If this is not unique then output -1.


If it is unique then output it.