Let X and Y be positive integers. We say that Y is a divisor of X if and only if there is a positive integer Z such that X = Y*Z. You will be given a String[] numbers. Each element in this String[] will contain a positive integer. For each of the given integers compute the sum of its positive divisors, itself excluded. Return a String[] containing the computed sums in the same order, with no unnecessary leading zeroes.
Class: PerfectNumbers Method: sumDivisors Parameters: String[] Returns: String[] Method signature: String[] sumDivisors(String[] numbers) (be sure your method is public)
All the numbers in the input, and all the numbers you should output will fit into 64-bit signed integer variables.
0) {"6"} Returns: {"6" } The divisors of 6 (other than 6 itself) are 1, 2, and 3. Their sum is 1+2+3 = 6. 1) {"28"} Returns: {"28" } Divisors of 28 are 1, 2, 4, 7, and 14, and their sum is 1+2+4+7+14 = 28. 2) {"4", "8", "16", "32"} Returns: {"3", "7", "15", "31" } 3) {"13", "47", "997"} Returns: {"1", "1", "1" } 4) {"510510"} Returns: {"1231314" } 510510 = 2*3*5*7*11*13*17 5) {"235152", "235326326132", "1234567890123"} Returns: {"461232", "176530725964", "411987510213" } 6) {"9999999999999"} Returns: {"4903272088641" } This is the largest valid input number. 7) {"1"} Returns: {"0" } And this is the smallest valid input.
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.