mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
style: enable NeedBraces in checkstyle (#5227)
* enable style NeedBraces * style: enable NeedBraces in checkstyle --------- Co-authored-by: Samuel Facchinello <samuel.facchinello@piksel.com>
This commit is contained in:
committed by
GitHub
parent
51fcc66345
commit
87b17e0571
@@ -19,7 +19,9 @@ public final class PerfectNumber {
|
||||
* @return {@code true} if {@code number} is perfect number, otherwise false
|
||||
*/
|
||||
public static boolean isPerfectNumber(int number) {
|
||||
if (number <= 0) return false;
|
||||
if (number <= 0) {
|
||||
return false;
|
||||
}
|
||||
int sum = 0;
|
||||
/* sum of its positive divisors */
|
||||
for (int i = 1; i < number; ++i) {
|
||||
@@ -37,7 +39,9 @@ public final class PerfectNumber {
|
||||
* @return {@code true} if {@code number} is perfect number, otherwise false
|
||||
*/
|
||||
public static boolean isPerfectNumber2(int n) {
|
||||
if (n <= 0) return false;
|
||||
if (n <= 0) {
|
||||
return false;
|
||||
}
|
||||
int sum = 1;
|
||||
double root = Math.sqrt(n);
|
||||
|
||||
@@ -58,7 +62,9 @@ public final class PerfectNumber {
|
||||
|
||||
// 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 (root == (int) root) {
|
||||
sum -= root;
|
||||
}
|
||||
|
||||
return sum == n;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user