由于超时,我的函数发现连续的总和未通过测试用例。谁能看到这个并且可能有助于优化?
static int consecutive(long num) {
return consecutiveHelper(num);
}
public static int consecutiveHelper(long num){
int factorNumber = 1;
int count = 0;
while(factorNumber <= num){
if(num % factorNumber == 0 && (factorNumber%2 != 0)){
count++;
}
factorNumber ++;
}
return count-1;
}