diff options
| -rwxr-xr-x | challenge-153/luca-ferrari/raku/ch-1.p6 | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-153/luca-ferrari/raku/ch-1.p6 b/challenge-153/luca-ferrari/raku/ch-1.p6 new file mode 100755 index 0000000000..801a647bd3 --- /dev/null +++ b/challenge-153/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,20 @@ +#!raku + +sub MAIN( Int $limit where { $limit > 0 } = 10 ) { + my @factorials = lazy gather { + for 0 .. $limit { + take 1 if $_ <= 1; + take [*] 1 .. $_ if $_ > 1; + } + }; + + my @numbers = lazy gather { + for 0 .. $limit { + take 0 if $_ == 0; + take 1 if $_ == 1; + take @factorials[ 0 .. $_ -1 ].sum if $_ > 1; + } + }; + + @numbers[ 0 .. $limit ].join( "\n" ).say; +} |
