Complete the code to print numbers from 1 to 5 using a range.
for (i in 1..[1]) { println(i) }
The range 1..5 includes numbers from 1 to 5, so the loop prints these numbers.
Complete the code to print numbers from 5 down to 1 using a range.
for (i in [1] downTo 1) { println(i) }
downTo which would create an empty range.The downTo function creates a decreasing range from 5 down to 1.
Fix the error in the code to print even numbers from 2 to 10 using a range with step.
for (i in 2..10 step [1]) { println(i) }
Using step 2 makes the loop count by twos, printing even numbers.
Fill both blanks to create a range that prints numbers from 1 to 10 but only odd numbers.
for (i in [1]..[2] step 2) { println(i) }
Starting at 1 and stepping by 2 up to 9 prints odd numbers: 1, 3, 5, 7, 9.
Fill all three blanks to create a range that prints numbers from 10 down to 1, stepping by 3.
for (i in [1] downTo [2] step [3]) { println(i) }
This loop counts down from 10 to 1, stepping by 3, printing 10, 7, 4, 1.
