Prime-power fraction decomposition (source code)

= Prime-power fraction decomposition
{title2=$a/b=n+\sum_i q_i/p_i^{n_i}$}

For a positive integer $b=\prod_i p_i^{n_i}$, every rational number $a/b$ has a unique representation $a/b=n+\sum_iq_i/p_i^{n_i}$ with $n\in\mathbb Z$ and $0\leq q_i<p_i^{n_i}$. With $B_i=b/p_i^{n_i}$, the coefficients satisfy $q_i\equiv aB_i^{-1}\pmod{p_i^{n_i}}$. Their existence and uniqueness use <modular multiplicative inverses> and the <Chinese remainder theorem>.