From 6dfdf9ce76aede3fcfc143496f5b596361a7ead2 Mon Sep 17 00:00:00 2001 From: blzimme000 Date: Mon, 10 Jan 2022 15:13:06 -0600 Subject: [PATCH] Slightly cleaner code --- src/com/company/Main.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/com/company/Main.java b/src/com/company/Main.java index e4f55ed..529be6c 100644 --- a/src/com/company/Main.java +++ b/src/com/company/Main.java @@ -22,10 +22,8 @@ public class Main { public static String factor(double a){ String thingtoreturn = ""; for (int i = 1; i < (.5*a); i++) { - if (i <= a / i) { - if (a % i == 0) { - thingtoreturn += "" + i + ", " + (a / i) + ". Sum: " + (i + (a / i)) + ". Difference: " + ((a / i) - i) + "\n"; - } + if (i <= a / i && a % i == 0) { + thingtoreturn += "" + i + ", " + (a / i) + ". Sum: " + (i + (a / i)) + ". Difference: " + ((a / i) - i) + "\n"; } } return thingtoreturn;