I think this can actually be `i * i > num`. In fact the `while` version could be

```rust
let mut ret = vec![];
while num % 2 == 0 { ret.push(2); num /= 2; }

let mut i = 3;
while i * i < num {
    while num % i == 0 { ret.push(i); num /= i; }
    i += 2;
}
```