Skip to content

Instantly share code, notes, and snippets.

@take-five
Created March 21, 2017 08:38
Show Gist options
  • Save take-five/0f1350388db04d7b7ca003750ad2ffa4 to your computer and use it in GitHub Desktop.
Save take-five/0f1350388db04d7b7ca003750ad2ffa4 to your computer and use it in GitHub Desktop.
backend-dev interview code example
class FibonacciCalculator
def initialize
end
def run
number = ARGV.first
puts "Fibonacci number for N=#{number}: #{fib(number.to_i)}"
end
private
def fib(n)
case
when n == 0 then 0
when n <= 2 then 1
else fib(n - 2) + fib(n - 1)
end
end
end
FibonacciCalculator.new.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment