text: Sieve of eratosthenes method to count number of prime factors .
code: for ( i = 2 ; i * i <= N ; i ++ ) { if ( arr [ i ] == 0 ) { for ( j = 2 * i ; j <= N ; j += i ) { arr [ j ] ++ ; } } arr [ i ] = 1 ; } var maxval = 0 , maxvar = 1 ;