Determine the set of factors for a given value. @param _value The value we wish to factorize. @param _max an upper bound on the value that can be chosen @return and array of factors of _value
(int _value, int _max)
| 128 | */ |
| 129 | |
| 130 | private static int[] getFactors(int _value, int _max) { |
| 131 | final int factors[] = new int[MAX_GROUP_SIZE]; |
| 132 | int factorIdx = 0; |
| 133 | |
| 134 | for (int possibleFactor = 1; possibleFactor <= _max; possibleFactor++) { |
| 135 | if ((_value % possibleFactor) == 0) { |
| 136 | factors[factorIdx++] = possibleFactor; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | return (Arrays.copyOf(factors, factorIdx)); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Create a one dimensional range <code>0.._globalWidth</code> with an undefined group size. |