Check if i and n - i doesn 't  contain k in them print i and n-i
if ( freqCount ( i . toString ( ) , String . fromCharCode ( k + 48 ) ) == 0 && freqCount ( ( n - i ) . toString ( ) , String . fromCharCode ( k + 48 ) ) == 0 ) { document . write ( " " + i + " " + ( n - i ) + " " ) ; flag = 1 ; break ; } }