Skip to content

Instantly share code, notes, and snippets.

@anolson
Created May 19, 2011 18:52
Show Gist options
  • Save anolson/981442 to your computer and use it in GitHub Desktop.
Save anolson/981442 to your computer and use it in GitHub Desktop.
require "test/unit"
class TestFibonachi < Test::Unit::TestCase
def test_fibonachi_numbers
numbers = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]
numbers.each_with_index { |number, index|
assert_equal number, Fibonachi.number(index)
}
end
end
class Fibonachi
def self.number(n)
n < 2 ? n : Fibonachi.number(n-2) + Fibonachi.number(n-1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment