U32/integer square root

Rather than trial division up to sqrt(n), it's generally better to use a sieve of some sort (e.g. of Eratosthenes), perhaps with a wheel for small primes, to avoid trialling division by composite numbers that you already know can't divide your candidate number.

std doesn't provide any built-in way to get an integer square root. If this is something you actually want, your best bet is to either to just use floating point math ((n as f64).sqrt() as u32) and cap your allowed input at 9×1015, the largest integer that fits in f64 without skipping (which is larger than u32::MAX at around 4×109), or pull in a crate implementation of isqrt (or implement it yourself).