Created
September 4, 2020 10:20
-
-
Save Aerdayne/7a3d95ed9b6a072a451d611143ea5c92 to your computer and use it in GitHub Desktop.
Ruby Fibonacci numbers preceding X one-liner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -> (num) { (1..num).reduce([0,1]) { |res, num| res.last(2).inject(:+) == num ? res << num : (next res) } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment