Fix the Loop Variable
This code tries to print a multiplication table, but it's using the wrong variable inside the loop. Can you fix it?
Expected output:
text
1 x 3 = 3 2 x 3 = 6 3 x 3 = 9
Hints:
- Look at what variable the loop creates and what's being used inside
- The loop variable should match what you use in the
println!call - Each line should multiply the loop number by 3
rust
fn main() {
let x = 10;
for i in 1..=3 {
println!("{} x 3 = {}", x, x * 3);
}
}