I am trying to implement a function with nested for loops. I am having trouble with the .step_by() function, however.
Here is my code:
fn get_prime_factors_below(n: i32) -> HashMap<i32, Vec<i32>> {
for i in 2..n / 2 + 1 {
for j in (i * 2..n).step_by(i) {
//
}
}
return factors;
}
This returns the following error when I try to compile it:
for j in (i * 2..n).step_by(i) {
------- ^ expected `usize`, found `i32`
|
arguments to this function are incorrect
Why does .step_by() expect a usize and doesn't work with an i32?