Created
April 13, 2017 15:29
-
-
Save olarclara/11db1bdb0046fcb6429c89c9c570662f 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
function recursiveFibonacci(n) { | |
if (n <= 1) { | |
return n; | |
} | |
else { | |
return recursiveFibonacci(n-1) + recursiveFibonacci(n-2); | |
} | |
} | |
function iterativeFibonacci(n) { | |
int x = 0, y = 1, z = 1; | |
for (int i = 0; i < n; i++) { | |
x = y; | |
y = z; | |
z = x + y; | |
} | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment