mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Cleaned up code for some packages (#5094)
* Cleaned up code of some packages --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
40cd4d86ef
commit
22310defcd
@@ -9,7 +9,7 @@ import java.util.Scanner;
|
||||
*/
|
||||
public class Fibonacci {
|
||||
|
||||
private static Map<Integer, Integer> map = new HashMap<>();
|
||||
private static final Map<Integer, Integer> map = new HashMap<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Methods all returning [0, 1, 1, 2, 3, 5, ...] for n = [0, 1, 2, 3, 4, 5, ...]
|
||||
@@ -106,7 +106,6 @@ public class Fibonacci {
|
||||
public static int fibBinet(int n) {
|
||||
double squareRootOf5 = Math.sqrt(5);
|
||||
double phi = (1 + squareRootOf5) / 2;
|
||||
int nthTerm = (int) ((Math.pow(phi, n) - Math.pow(-phi, -n)) / squareRootOf5);
|
||||
return nthTerm;
|
||||
return (int) ((Math.pow(phi, n) - Math.pow(-phi, -n)) / squareRootOf5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user