Fixed difference/duplicates bug.
This commit is contained in:
parent
78bf886268
commit
6c5a762128
3 changed files with 12 additions and 21 deletions
|
@ -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
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -4,22 +4,17 @@ import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Scanner scan = new Scanner(System.in);
|
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");
|
System.out.println("Note: Must be positive. If negative, remove negative and make one factor negative");
|
||||||
double a = scan.nextDouble();
|
double a = scan.nextDouble();
|
||||||
|
|
||||||
for (int i = 1; i < (.5*a); i++) {
|
for (int i = 1; i < (.5*a); i++) {
|
||||||
|
if (i <= a / i) {
|
||||||
if (a % i == 0) {
|
if (a % i == 0) {
|
||||||
System.out.print("" + i + ", " + (a/i) + ". Sum: " + (i + (a/i)));
|
System.out.println("" + i + ", " + (a / i) + ". Sum: " + (i + (a / i)) + ". Difference: " + ((a / i) - 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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue