Last updated
Was this helpful?
Last updated
Was this helpful?
The first twenty numbers:
Here we use a multi
declaration with a constant parameter to match the degenerate case. We use copy
parameters when we wish to reuse the formal parameter as a mutable variable within the function. (Parameters default to readonly in Raku.) Note the use of gather
/take
as the final statement in the function, which is a common Raku idiom to set up a coroutine within a function to return a lazy list on demand.
Note also the '×' above is not ASCII 'x', but U+00D7 MULTIPLICATION SIGN. Raku does Unicode natively.
Same output as above.
Alternately, use a module:
Here is a solution inspired from . It doesn't use &is-prime.