Iterate through numbers from 2 to sqrt ( N ) and store divisors of N
for ( var i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( parseInt ( n / i ) == i ) { divisor [ j ] = i ; j += 1 ; } else { divisor [ j ] = i ; divisor [ j + 1 ] = parseInt ( n / i ) ; j += 2 ; } } }