mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-25 05:22:39 +08:00
style: enable MultipleVariableDeclarations
in checkstyle (#5175)
Co-authored-by: vaibhav <vaibhav.waghmare@techprescient.com>
This commit is contained in:
@ -24,7 +24,8 @@ public final class AutomorphicNumber {
|
||||
public static boolean isAutomorphic(long n) {
|
||||
if (n < 0) return false;
|
||||
long square = n * n; // Calculating square of the number
|
||||
long t = n, numberOfdigits = 0;
|
||||
long t = n;
|
||||
long numberOfdigits = 0;
|
||||
while (t > 0) {
|
||||
numberOfdigits++; // Calculating number of digits in n
|
||||
t /= 10;
|
||||
|
@ -13,7 +13,10 @@ public final class DeterminantOfMatrix {
|
||||
// Determinant calculator
|
||||
//@return determinant of the input matrix
|
||||
static int determinant(int[][] a, int n) {
|
||||
int det = 0, sign = 1, p = 0, q = 0;
|
||||
int det = 0;
|
||||
int sign = 1;
|
||||
int p = 0;
|
||||
int q = 0;
|
||||
if (n == 1) {
|
||||
det = a[0][0];
|
||||
} else {
|
||||
|
@ -24,7 +24,8 @@ public final class FFT {
|
||||
*/
|
||||
static class Complex {
|
||||
|
||||
private double real, img;
|
||||
private double real;
|
||||
private double img;
|
||||
|
||||
/**
|
||||
* Default Constructor. Creates the complex number 0.
|
||||
|
@ -41,7 +41,8 @@ public final class FindKthNumber {
|
||||
}
|
||||
|
||||
private static int findKthMax(int[] nums, int k) {
|
||||
int start = 0, end = nums.length;
|
||||
int start = 0;
|
||||
int end = nums.length;
|
||||
while (start < end) {
|
||||
int pivot = partition(nums, start, end);
|
||||
if (k == pivot) {
|
||||
|
@ -8,7 +8,8 @@ public final class Gaussian {
|
||||
|
||||
public static ArrayList<Double> gaussian(int mat_size, ArrayList<Double> matrix) {
|
||||
ArrayList<Double> answerArray = new ArrayList<Double>();
|
||||
int i, j = 0;
|
||||
int i;
|
||||
int j = 0;
|
||||
|
||||
double[][] mat = new double[mat_size + 1][mat_size + 1];
|
||||
double[][] x = new double[mat_size][mat_size + 1];
|
||||
@ -43,7 +44,8 @@ public final class Gaussian {
|
||||
// calculate the x_1, x_2, ... values of the gaussian and save it in an arraylist.
|
||||
public static ArrayList<Double> valueOfGaussian(int mat_size, double[][] x, double[][] mat) {
|
||||
ArrayList<Double> answerArray = new ArrayList<Double>();
|
||||
int i, j;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for (i = 0; i < mat_size; i++) {
|
||||
for (j = 0; j <= mat_size; j++) {
|
||||
|
@ -11,9 +11,10 @@ final class KeithNumber {
|
||||
// user-defined function that checks if the given number is Keith or not
|
||||
static boolean isKeith(int x) {
|
||||
// List stores all the digits of the X
|
||||
ArrayList<Integer> terms = new ArrayList<Integer>();
|
||||
ArrayList<Integer> terms = new ArrayList<>();
|
||||
// n denotes the number of digits
|
||||
int temp = x, n = 0;
|
||||
int temp = x;
|
||||
int n = 0;
|
||||
// executes until the condition becomes false
|
||||
while (temp > 0) {
|
||||
// determines the last digit of the number and add it to the List
|
||||
@ -25,7 +26,8 @@ final class KeithNumber {
|
||||
}
|
||||
// reverse the List
|
||||
Collections.reverse(terms);
|
||||
int next_term = 0, i = n;
|
||||
int next_term = 0;
|
||||
int i = n;
|
||||
// finds next term for the series
|
||||
// loop executes until the condition returns true
|
||||
while (next_term < x) {
|
||||
|
@ -30,7 +30,8 @@ public final class LeastCommonMultiple {
|
||||
* get least common multiple from two number
|
||||
*/
|
||||
public static int lcm(int num1, int num2) {
|
||||
int high, num3;
|
||||
int high;
|
||||
int num3;
|
||||
int cmv = 0;
|
||||
/*
|
||||
* value selection for the numerator
|
||||
|
@ -13,7 +13,8 @@ public final class NonRepeatingElement {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try (Scanner sc = new Scanner(System.in)) {
|
||||
int i, res = 0;
|
||||
int i;
|
||||
int res = 0;
|
||||
System.out.println("Enter the number of elements in the array");
|
||||
int n = sc.nextInt();
|
||||
if ((n & 1) == 1) {
|
||||
@ -42,7 +43,8 @@ public final class NonRepeatingElement {
|
||||
|
||||
// Finding the rightmost set bit
|
||||
res = res & (-res);
|
||||
int num1 = 0, num2 = 0;
|
||||
int num1 = 0;
|
||||
int num2 = 0;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if ((res & arr[i]) > 0) { // Case 1 explained below
|
||||
|
@ -59,7 +59,9 @@ public final class PollardRho {
|
||||
* @throws RuntimeException object if GCD of given number cannot be found
|
||||
*/
|
||||
static int pollardRho(int number) {
|
||||
int x = 2, y = 2, d = 1;
|
||||
int x = 2;
|
||||
int y = 2;
|
||||
int d = 1;
|
||||
while (d == 1) {
|
||||
// tortoise move
|
||||
x = g(x, number);
|
||||
|
@ -56,7 +56,8 @@ public final class PrimeCheck {
|
||||
*/
|
||||
public static boolean fermatPrimeChecking(int n, int iteration) {
|
||||
long a;
|
||||
int up = n - 2, down = 2;
|
||||
int up = n - 2;
|
||||
int down = 2;
|
||||
for (int i = 0; i < iteration; i++) {
|
||||
a = (long) Math.floor(Math.random() * (up - down + 1) + down);
|
||||
if (modPow(a, n - 1, n) != 1) {
|
||||
|
Reference in New Issue
Block a user