/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Name: COS 126 Staff * * Login: cos126 * * Precept: P00 * * * * Description: Prints the aliquot sum of the command-line input. * * * * Dependencies: StdOut.java * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ public class Aliquot { public static void main(String[] args) { int n = Integer.parseInt(args[0]); int aliquotSum = 0; // check (1, 2, ..., n/2) for factors of n for (int i = 1; i <= n/2; i++) if (n % i == 0) aliquotSum += i; StdOut.println("The Aliquot sum of " + n + " is " + aliquotSum); } }