Skip to content

Instantly share code, notes, and snippets.

@hakobe
Created July 1, 2009 08:38
Show Gist options
  • Select an option

  • Save hakobe/138677 to your computer and use it in GitHub Desktop.

Select an option

Save hakobe/138677 to your computer and use it in GitHub Desktop.
object Fib {
def fib(n:Int) : Int = n match {
case 0 => 1
case 1 => 1
case _ => fib(n-1) + fib(n-2)
}
def main(args:Array[String]) = {
(1 to 10).foreach( n => println(fib(n)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment