diff --git a/Java/Main.java b/Java/Main.java
@@ -1,5 +1,3 @@
-package conjecture;
-
// The following program is a simple test for the following conjecture:
// Let S: N -> N be the sum of the digits of a positive integer.
@@ -21,7 +19,7 @@ public class Main {
} else {
System.exit(SUCCESS);
}
- } catch (InputMismatchException error) {
+ } catch (Exception error) {
System.exit(INVALID_INPUT);
}
@@ -42,7 +40,7 @@ public class Main {
}
private static int[] getSums(int max) {
- int maxRange = 2 * (max + 1);
+ int maxRange = 2 * max + 1;
int[] sums = new int[maxRange];
for (int i = 0; i < maxRange; i++)
@@ -51,8 +49,11 @@ public class Main {
return sums;
}
+ /**
+ * Calculates the sum of the digits of a positive integer.
+ */
private static int sumDigits(int n) {
- int num = Math.abs(n), sum = 0;
+ int num = n, sum = 0;
while (num > 0) {
sum += num % 10;