*This post is part of a series on Mohammad Anwar’s excellent Perl Weekly Challenge, where Perl and Raku hackers submit solutions to two different challenges every week. (It’s a lot of fun, if you’re into that sort of thing.)*

Happy new year! We are on Week 41, and this is Challenge #2.

The Leonardo Numbers (A001595) are a simple recursively defined sequence:

\(L(n) = \begin{cases}

1 & \text{if } n \lt 2 \\

1 + L(n – 1) + L(n – 2) & \text{if } n \geq 2

\end{cases}\)

The sequence starts: 1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361, 13529, 21891, …

You’ll note this sequence is very similar to the well-known Fibonacci sequence, which differs only in that the Fibonacci sequence does not have the + 1 term, and starts at F(0) = 0.

Continue reading “Leonardo Numbers”