Step Range in Kotlin

Level 238 keystrokes

Iterates over a range in steps of 2.

Kotlin code

// step 2 moves by 2 instead of 1 through the range
// 0..10 step 2 gives 0, 2, 4, 6, 8, 10 (10 is included)
1for (i in 0..10 step 2) {
// Prints each value on its own line
2 println(i)
3}

Output

0
2
4
6
8
10
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Kotlin code and how often they appear.

  • .× 2
  • (× 2
  • )× 2
  • {× 1
  • }× 1

More Kotlin examples at level 2

← Kotlin typing practice