check for all the possible numbers that can divide it
for ( var i = 3 ; i <= parseInt ( Math . sqrt ( n ) ) ; i += 2 ) { count = 0 ; while ( n % i == 0 ) { count ++ ; n = parseInt ( n / i ) ; } if ( count != 0 ) document . write ( i + " " + count + " " ) ; }