This could also be:

    let mut i = 2;
    while i <= sqrt {
        ....
        i += 1;
    }

Not sure which is better, a mutable variable, or nested loop.