Last active
April 8, 2017 20:35
-
-
Save kklimuk/6035b9f11be452b95646f573db37be21 to your computer and use it in GitHub Desktop.
This file contains 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
class FibonacciCalculator | |
include RubyMemoized | |
def calculate(n) | |
return n if (0..1).include?(n) | |
calculate(n - 1) + calculate(n - 2) | |
end | |
memoized | |
def memoized_calculate(n) | |
return n if (0..1).include?(n) | |
memoized_calculate(n - 1) + memoized_calculate(n - 2) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment