Function to increment the count for each factor of given val
function IncrementFactors ( count , val ) { for ( let i = 1 ; i * i <= val ; i ++ ) { if ( val % i == 0 ) { if ( i == parseInt ( val / i ) ) { count [ i ] ++ ; } else { count [ i ] ++ ; count [ parseInt ( val / i ) ] ++ ; } } } }