text: Count numbers in range such that digits in it and it 's product with q are unequal | C # program for above approach ; Function to check if all of the digits in a number and it 's product with q  are unequal or not ; convert first number into string ; Insert elements from 1 st number to hash ; Calculate corresponding product ; Convert the product to string ; Using the hash check if any digit of product matches with the digits of input number ; If yes , return false ; Else , return true ; Function to count numbers in the range [ l , r ] such that all of the digits of the number and it 's product with q are unequal ; check for every number between l and r ; Driver Code ; Function call
code: using System ; class GfG { static bool checkIfUnequal ( int n , int q ) { string s1 = n . ToString ( ) ; int [ ] a = new int [ 26 ] ; for ( int i = 0 ; i < s1 . Length ; i ++ ) a [ s1 [ i ] - '0' ] ++ ; int prod = n * q ; string s2 = prod . ToString ( ) ; for ( int i = 0 ; i < s2 . Length ; i ++ ) { if ( a [ s2 [ i ] - '0' ] ) return false ; } return true ; } static int countInRange ( int l , int r , int q ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( checkIfUnequal ( i , q ) ) count ++ ; } return count ; } public static void Main ( ) { int l = 10 , r = 12 , q = 2 ; Console . WriteLine ( countInRange ( l , r , q ) ) ; } }