optimization
This commit is contained in:
parent
8c5ec652f6
commit
34869cb5cb
@ -25,7 +25,7 @@ public class AliquotSum {
|
|||||||
*/
|
*/
|
||||||
public static int aliquotSum(int number) {
|
public static int aliquotSum(int number) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 1; i < number; ++i) {
|
for (int i = 1, limit = number / 2; i <= limit; ++i) {
|
||||||
if (number % i == 0) {
|
if (number % i == 0) {
|
||||||
sum += i;
|
sum += i;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user