Slightly cleaner code
This commit is contained in:
parent
d79f0ca19d
commit
6dfdf9ce76
1 changed files with 2 additions and 4 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue