Slightly cleaner code

This commit is contained in:
blzimme000 2022-01-10 15:13:06 -06:00
parent d79f0ca19d
commit 6dfdf9ce76

View file

@ -22,10 +22,8 @@ public class Main {
public static String factor(double a){ public static String factor(double a){
String thingtoreturn = ""; String thingtoreturn = "";
for (int i = 1; i < (.5*a); i++) { for (int i = 1; i < (.5*a); i++) {
if (i <= a / i) { if (i <= a / i && a % i == 0) {
if (a % i == 0) { thingtoreturn += "" + i + ", " + (a / i) + ". Sum: " + (i + (a / i)) + ". Difference: " + ((a / i) - i) + "\n";
thingtoreturn += "" + i + ", " + (a / i) + ". Sum: " + (i + (a / i)) + ". Difference: " + ((a / i) - i) + "\n";
}
} }
} }
return thingtoreturn; return thingtoreturn;