Skip to content

Instantly share code, notes, and snippets.

@karapetyan
Last active September 14, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karapetyan/a0c2dbc5336effacfa08 to your computer and use it in GitHub Desktop.
Save karapetyan/a0c2dbc5336effacfa08 to your computer and use it in GitHub Desktop.
class Fibonacchi
def initialize(path = "./input")
File.open(path, "r") do |file|
file.each_line do |line|
puts fibonacchi(line.chomp.to_i)
end
end
end
private
def fibonacchi(number)
fib = [0, 1]
while number > fib.count do
fib << fib[fib.count - 1] + fib[fib.count - 2]
end
fib.last
end
end
Fibonacchi.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment