Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Count by Twos

Use a for loop with .step_by() to print the even numbers from 2 to 10, one per line.

Expected output:

text
2
4
6
8
10

Hints:

  • Use an inclusive range 2..=10
  • Chain .step_by(2) to skip every other number
  • Don't forget the parentheses around the range!
rust
fn main() {
}