P-adic valuation (source code)

= P-adic valuation
{c}
{title2=$v_p$}
{wiki}

= Prime exponent
{synonym}

For a <prime number> $p$ and a nonzero <integer> $N$, the <P-adic valuation> counts the exponent of $p$ in its <prime factorization>:
$$
v_p(N)=\max\{a\in\mathbb Z_{\geq0}:p^a\mid N\}.
$$
For $72=2^3\cdot3^2$, it gives $v_2(72)=3$, $v_3(72)=2$, and $v_5(72)=0$. The sign of a nonzero <integer> does not change these <prime exponents>. Relative to an ordered <factor base>, the valuations supply the coordinates of its <exponent vector>.

The <P-adic valuation> extends to nonzero <rational numbers> by $v_p(a/b)=v_p(a)-v_p(b)$. For example, $v_5(72/25)=-2$ records a factor in the denominator instead of the numerator. <Multiplication> adds valuations, $v_p(xy)=v_p(x)+v_p(y)$; this is the arithmetic reason why adding exponent vectors can make a product a square. In particular, a positive <integer> is a <square of a number> precisely when all its <prime exponents> are <even integers>, the criterion used by a <factor base>.