Created
February 16, 2020 19:11
-
-
Save msiddiqi/e2c1ce51aa384e76666becd77c256a6c 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 getNthFibnacci(n: Int): Int = { | |
if (n == 0 || n == 1) { | |
return n | |
} | |
return getNthFibnacci(n - 1) + getNthFibnacci(n - 2) | |
} | |
print(getNthFibnacci(7)) | |
// 0 1 1 2 3 5 8 13 | |
//OUTPUT: 13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment