Created
July 11, 2018 15:23
-
-
Save lalabuy948/6c79d301e83a3fc22ad04be161c696c6 to your computer and use it in GitHub Desktop.
Fibonacci function in Java
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
private static long fibonacci(int n) { | |
long c = 1; | |
long b = 0; | |
long a = 0; | |
for (int i = 1; i <= n; i++) { | |
a = c + b; | |
c = b; | |
b = a; | |
} | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment