Course of Raku / Advanced / More about built-in types / Sequences / Exercises / Odd numbers

Solution: Odd numbers

Here is a possible solution to the task.

Code

say 1, 3 ... 19;

🦋 You can find the source code in the file odd-numbers.raku.

Output

(1 3 5 7 9 11 13 15 17 19)

Comments

  1. The two starting values 1, 3 set the step to two, so the sequence counts up by two.

  2. The sequence stops as soon as it reaches the endpoint 19.

Course navigation

Odd numbers   |   Powers of two