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

View File

@ -6,8 +6,8 @@ import java.util.Scanner;
public class MatrixChainMultiplication {
private static Scanner scan = new Scanner(System.in);
private static ArrayList<Matrix> mArray = new ArrayList<>();
private static final Scanner scan = new Scanner(System.in);
private static final ArrayList<Matrix> mArray = new ArrayList<>();
private static int size;
private static int[][] m;
private static int[][] s;
@ -115,9 +115,9 @@ public class MatrixChainMultiplication {
class Matrix {
private int count;
private int col;
private int row;
private final int count;
private final int col;
private final int row;
Matrix(int count, int col, int row) {
this.count = count;