Prime-exponent difference (source code)

= Prime-exponent difference

For positive <integers> $a,b$ and a <prime> $p$, their <prime-exponent difference> is $v_p(a)-v_p(b)$, where $v_p$ is the exponent in <prime factorization>. This is the exponent of $p$ in the positive <rational number> $a/b$, and it may be negative.

For $a=12=2^2\cdot3$ and $b=18=2\cdot3^2$, the differences are $1$ at $2$ and $-1$ at $3$, giving $a/b=2/3$. The quotient is an <integer> exactly when every difference is nonnegative. It is a rational $k$th power exactly when every difference is divisible by $k$, making exponent differences useful for perfect-power and divisibility tests.