Skip to content

Instantly share code, notes, and snippets.

@Aerdayne
Created September 4, 2020 10:20
Show Gist options
  • Select an option

  • Save Aerdayne/7a3d95ed9b6a072a451d611143ea5c92 to your computer and use it in GitHub Desktop.

Select an option

Save Aerdayne/7a3d95ed9b6a072a451d611143ea5c92 to your computer and use it in GitHub Desktop.
Ruby Fibonacci numbers preceding X one-liner
-> (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