style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@@ -18,28 +18,24 @@ public class AliquotSum {
* @return aliquot sum of given {@code number}
*/
public static int getAliquotValue(int number) {
var sumWrapper = new Object() {
int value = 0;
};
var sumWrapper = new Object() { int value = 0; };
IntStream
.iterate(1, i -> ++i)
IntStream.iterate(1, i -> ++i)
.limit(number / 2)
.filter(i -> number % i == 0)
.forEach(i -> sumWrapper.value += i);
return sumWrapper.value;
}
/**
/**
* Function to calculate the aliquot sum of an integer number
*
* @param n a positive integer
* @return aliquot sum of given {@code number}
*/
public static int getAliquotSum(int n) {
if (n <= 0)
return -1;
if (n <= 0) return -1;
int sum = 1;
double root = Math.sqrt(n);
/*
@@ -56,9 +52,9 @@ public class AliquotSum {
sum += i + n / i;
}
}
// if n is a perfect square then its root was added twice in above loop, so subtracting root from sum
if (root == (int) root)
sum -= root;
// if n is a perfect square then its root was added twice in above loop, so subtracting root
// from sum
if (root == (int) root) sum -= root;
return sum;
}
}