Skip to content

Instantly share code, notes, and snippets.

@semmons99
Last active August 29, 2015 14:25
Show Gist options
  • Save semmons99/43b554293b1a8c62359e to your computer and use it in GitHub Desktop.
Save semmons99/43b554293b1a8c62359e to your computer and use it in GitHub Desktop.
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "contracts"
end
include Contracts
Contract 0 => 0
def fib(_)
0
end
Contract 1 => 1
def fib(_)
1
end
Contract Num => Num
def fib(n)
fib(n-1) + fib(n-2)
end
puts fib(0)
puts fib(1)
puts fib(15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment