Fixed difference/duplicates bug.

This commit is contained in:
blzimme000 2021-12-15 15:14:25 -06:00
parent 78bf886268
commit 6c5a762128
3 changed files with 12 additions and 21 deletions

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -4,22 +4,17 @@ import java.util.Scanner;
public class Main {
public static void main(String args[]) {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Input the number:");
System.out.println("Input an integer to be factored:");
System.out.println("Note: Must be positive. If negative, remove negative and make one factor negative");
double a = scan.nextDouble();
for (int i = 1; i < (.5*a); i++) {
if (i <= a / i) {
if (a % i == 0) {
System.out.print("" + i + ", " + (a/i) + ". Sum: " + (i + (a/i)));
//Adds difference (might not work, but not sure if that's because of bad online compiler)
if (i < a%i){
System.out.println(". Difference: " + (i - (a/i)));
} else {
System.out.println(". Difference: " + ((a/i) - i));
System.out.println("" + i + ", " + (a / i) + ". Sum: " + (i + (a / i)) + ". Difference: " + ((a / i) - i));
}
}
}