It's not just the cost of the `sqrt`. This technique saves quadratically much work, e.g. for `num == 2^4 * 17`, the square root is a bit over 16.

Both my suggestion and your `for` loop will quickly reduce `num` to 17 (dividing out all the 2s), but your implementation will walk all the way up to 16 (and never hit the shortcircuit), while mine will stop at i == 5.

In any case, the cost of a multiply will pale in comparison to the moduluses and divisions. Also, you can use `(i + 2)^2 == i^2 + 4*i + 4` to compute the squares incrementally without remultiplying each time:

```rust
let mut i = 3;
let mut isqr = 9;
while isqr <= num {
     while num % i == 0 { ret.push(i); num /= i }
     isqr += 4 * (i  + 1);
     i += 2;
}
```