Hello, I am working on a java program that finds perfect numbers. I need to make it run more efficiently by touching up the computation I have in my factorSum method. Heres what I have so far:
public static int factorSum(int testNum)
{
//Initialize local variable accumulator to zero.
int accumulator = 0;
for (int counter = 2; counter < Math.sqrt(testNum); counter++)
{
if (testNum % counter == 0 && counter != testNum)
{
accumulator = (counter + (testNum / counter));
}//end if statement
}//end for loop
//return accumulator to isFactor method
return accumulator;
}//end factorSum method
It isnt outputting the perfect numbers. Can someone guide me in the right direction to get this computational code correct?