Last active
September 14, 2015 14:20
-
-
Save karapetyan/a0c2dbc5336effacfa08 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 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 |
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
100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment