n must be odd at this point , thus skip the even numbers and iterate only odd numbers
for ( var i = 3 ; i <= parseInt ( Math . sqrt ( n ) ) ; i += 2 ) { while ( n % i == 0 ) { maxPrime = i ; n = parseInt ( n / i ) ; } }