What is your task? Finding the lowest number with over 500 factors? While little things could be optimised (line 16 could have i*i<=n condition, since all factors (except for the root) come in pairs), I think there may be a simple way to assemble such number.
thanks guys, my orignal program finished running, but i will take a look at the sum factors equation, even though it is slightly different than what im looking for (number of factors vs sum of factors)