I am looking for a way to implement division in modular arithmetic using modulo prime.
The method I found in math books is to try $u$ such that
$au \equiv 1 \pmod{p}$
$b/a \equiv bu \pmod{p}$
where $a, b, u \in Z_p$ (remainder class modulo a prime $p$). But trying things is probably not a good and fast approach (as it seems to me it has linear complexity and my $p$ can be big, up to $10^9$). What is the right way to do division in modulo prime?