Function for finding smallest prime factors for every integer
function smallestPrimeFactors ( ) { for ( let i = 0 ; i < 100005 ; i ++ ) spf [ i ] = - 1 ; for ( let i = 2 ; i * i < 100005 ; i ++ ) { for ( let j = i ; j < 100005 ; j += i ) { if ( spf [ j ] == - 1 ) { spf [ j ] = i ; } } } }