Skip to content

Instantly share code, notes, and snippets.

@khalidr
Last active June 14, 2019 18:49
Show Gist options
  • Save khalidr/aba510a1e597345a3e8a1622e8d335be to your computer and use it in GitHub Desktop.
Save khalidr/aba510a1e597345a3e8a1622e8d335be to your computer and use it in GitHub Desktop.
def fib1(i:Int) = {
//0,1,1,2,3,5,8,11
def loop(n1:Int,n2:Int0, idx:Int=1):Int = {
idx match {
case 0 => n2
case 1 => n1
case _ => loop(n2, n1+n2, idx-1)
}
}
loop(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment