Last active
June 14, 2019 18:49
-
-
Save khalidr/aba510a1e597345a3e8a1622e8d335be 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
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