Is it possible and/or necessary to convert the following code to a version using iterators? The code should take an integer and factorize it into its prime factors. I also implemented a version using an incremental sieve, but this algorithm came out about an order of magnitude faster. (9 ms vs 130 ms).

## (Bad) algorithm explanation

The algorithm works by starting at two, dividing the input by the current prime candidate until the answer isn't divisible any more, then goes to the next odd number. This way, even if the next odd number isn't prime, it will just immediately be filtered out since the remaining number had been divided by that composite factor until it can't be divided any more via division by its prime factors.

The reason to use iterators would be to be able to know the size of the `Vec`

before starting to write into it, thus saving reallocations.

```
pub fn factors(n: u64) -> Vec<u64> {
let mut factors = vec![];
let mut factor = 2;
let mut n = n;
while n > 1 {
while n % factor == 0 {
factors.push(factor);
n /= factor;
}
factor = if factor == 2 { 3 } else { factor + 2 };
}
factors
}
```