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

@ -21,9 +21,8 @@ public class AmicableNumber {
public static void main(String[] args) {
AmicableNumber.findAllInRange(1, 3000);
/* Res -> Int Range of 1 till 3000there are 3Amicable_numbers These are 1: = ( 220,284) 2: = ( 1184,1210)
3: = ( 2620,2924) So it worked */
/* Res -> Int Range of 1 till 3000there are 3Amicable_numbers These are 1: = ( 220,284)
2: = ( 1184,1210) 3: = ( 2620,2924) So it worked */
}
/**
@ -32,8 +31,9 @@ public class AmicableNumber {
* @return
*/
static void findAllInRange(int startValue, int stopValue) {
/* the 2 for loops are to avoid to double check tuple. For example (200,100) and (100,200) is the same calculation
* also to avoid is to check the number with it self. a number with itself is always a AmicableNumber
/* the 2 for loops are to avoid to double check tuple. For example (200,100) and (100,200)
* is the same calculation also to avoid is to check the number with it self. a number with
* itself is always a AmicableNumber
* */
StringBuilder res = new StringBuilder();
int countofRes = 0;
@ -42,22 +42,14 @@ public class AmicableNumber {
for (int j = i + 1; j <= stopValue; j++) {
if (isAmicableNumber(i, j)) {
countofRes++;
res.append(
"" + countofRes + ": = ( " + i + "," + j + ")" + "\t"
);
res.append("" + countofRes + ": = ( " + i + "," + j + ")"
+ "\t");
}
}
}
res.insert(
0,
"Int Range of " +
startValue +
" till " +
stopValue +
" there are " +
countofRes +
" Amicable_numbers.These are \n "
);
res.insert(0,
"Int Range of " + startValue + " till " + stopValue + " there are " + countofRes
+ " Amicable_numbers.These are \n ");
System.out.println(res);
}
@ -69,12 +61,8 @@ public class AmicableNumber {
* otherwise false
*/
static boolean isAmicableNumber(int numberOne, int numberTwo) {
return (
(
recursiveCalcOfDividerSum(numberOne, numberOne) == numberTwo &&
numberOne == recursiveCalcOfDividerSum(numberTwo, numberTwo)
)
);
return ((recursiveCalcOfDividerSum(numberOne, numberOne) == numberTwo
&& numberOne == recursiveCalcOfDividerSum(numberTwo, numberTwo)));
}
/**