Find two numbers whose sum is N and does not contain any digit as K | Javascript program for the above approach ; Function to find two numbers whose sum is N and do not contain any digit as k ; Check every number i and ( n - i ) ; Check if i and n - i doesn 't  contain k in them print i and n-i ; Check if flag is 0 then print - 1 ; Given N and K ; Function call
function freqCount ( str , k ) { var count = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] == k ) count ++ ; } return count ; } function findAandB ( n , k ) { var flag = 0 ; for ( var i = 1 ; i < 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 ; } } if ( flag == 0 ) cout + - 1 ; } var N = 100 ; var K = 0 ; findAandB ( N , K ) ;