Updated to fix infinite loop and time

This commit is contained in:
2018-09-27 00:07:47 -04:00
parent b98db8f9b5
commit 2908ec0b11

View File

@@ -17,6 +17,7 @@ while(~found)
if(mod(numSum, divCounter) == 0) if(mod(numSum, divCounter) == 0)
numDivisors += 2; numDivisors += 2;
end end
++divCounter;
end end
%Check if there are enough divisors %Check if there are enough divisors
@@ -33,7 +34,7 @@ endTime = clock();
number = numSum number = numSum
highestNumber = counter - 1 highestNumber = counter - 1
numDivisors = numDivisors numDivisors = numDivisors
totalTime = etime(endTime - startTime) totalTime = etime(endTime, startTime)
%Cleanup the variables %Cleanup the variables
clear found; clear found;
@@ -46,3 +47,4 @@ clear endTime;
clear totalTime; clear totalTime;
clear numDivisors; clear numDivisors;
clear divCounter; clear divCounter;
clear ans;