DEV Community

Discussion on: Let's Get Clever #1: Fibonacci Sequence

Collapse
 
chsanch profile image
Christian Sánchez • Edited

In Perl 6 you can do something like this:

my @fib = 0, 1, * + * ... *

This make uses of the ... sequence operator, which will produce (possibly lazy) generic sequences on demand.

Then you can get the first 10 Fibonacci numbers:

@fib[0..10]

More detailed explanation about this (not mine) could be found at: perl6.online/2018/12/15/playing-wi... and perl6advent.wordpress.com/2010/12/...

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

If you could get this to return a single number for value n, you'd be set up to get the bonus points for no loops or recursion! 🔂