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:
Kanivets Kateryna
2024-04-02 21:26:06 +02:00
committed by GitHub
parent 40cd4d86ef
commit 22310defcd
12 changed files with 23 additions and 29 deletions

View File

@@ -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);
}
}