this post was submitted on 31 Oct 2024
367 points (98.4% liked)
196
16553 readers
1697 users here now
Be sure to follow the rule before you head out.
Rule: You must post before you leave.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Using Haskell you can write it way more concise:
However, we can be way smarter by only defining the 2 base cases and then a recursive definition for all other numbers:
It's having a hard time with negative numbers, but honestly that's quite a mood
Recursion is its own reward