Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming / Lazy and infinite sequences / Exercises

The first multiples of seven

Problem

Starting from the infinite range 1..*, build the multiples of seven and print the first five of them. Do not store the infinite sequence in an array — pull just the first five.

Example

The program prints:

(7 14 21 28 35)

Solution

See the solution

Course navigation

Quiz — Lazy sequences   |   Solution: The first multiples of seven