Problem Statement
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.
Definition
- Class:
- PerfectNumbers
- Method:
- sumDivisors
- Parameters:
- String[]
- Returns:
- String[]
- Method signature:
- String[] sumDivisors(String[] numbers)
- (be sure your method is public)
Notes
- All the numbers in the input, and all the numbers you should output will fit into 64-bit signed integer variables.
Constraints
- numbers will contain between 1 and 50 elements, inclusive.
- Each element in numbers contains between 1 and 13 digits ('0'-'9'), inclusive.
- No element in numbers will contain leading zeroes.
Examples
{"6"}Returns: {"6" }The divisors of 6 (other than 6 itself) are 1, 2, and 3. Their sum is 1+2+3 = 6.{"28"}Returns: {"28" }Divisors of 28 are 1, 2, 4, 7, and 14, and their sum is 1+2+4+7+14 = 28.{"4", "8", "16", "32"}Returns: {"3", "7", "15", "31" }{"13", "47", "997"}Returns: {"1", "1", "1" }{"510510"}Returns: {"1231314" }510510 = 2*3*5*7*11*13*17{"235152", "235326326132", "1234567890123"}Returns: {"461232", "176530725964", "411987510213" }{"9999999999999"}Returns: {"4903272088641" }This is the largest valid input number.{"1"}Returns: {"0" }And this is the smallest valid input.