human
Queries to count numbers from given range which are divisible by all its digits | Function to check if a number is divisible by all of its non - zero digits or not.
Stores the number.
Iterate over the digits of the numbers.
If digit of number is non - zero.
If number is not divisible by its current digit.
Update n.
Function to count of numbers which are divisible by all of its non - zero digits in the range [ 1 , i ].
Stores count of numbers which are divisible by all of its non - zero digits in the range [ 1 , i ].
Iterate over the range [ 1 , Max ].
Update.
Traverse the array , arr [ ].
Driver Code"
Solution in Python:
 What is a code to queries to count numbers from given range which are divisible by all its digits and the other steps required?
assistant
#Here is code to queries to count numbers from given range which are divisible by all its digits and the other steps required.
 def CheckDivByAllDigits ( number ) :
	n = number
	while ( n > 0 ) :
		if ( n % 10 ) :
			if ( number % ( n % 10 ) ) :
				return False
		n //= 10
	return True
def cntNumInRang ( arr , N ) :
	global Max
	prefCntDiv = [ 0 ] * Max
	for i in range ( 1 , Max ) :
		prefCntDiv [ i ] = prefCntDiv [ i - 1 ] + ( CheckDivByAllDigits ( i ) )
	for i in range ( N ) :
		print ( prefCntDiv [ arr [ i ] [ 1 ] ] - prefCntDiv [ arr [ i ] [ 0 ] - 1 ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	arr = [ [ 1 , 5 ] , [ 12 , 14 ] ]
	Max = 1000005
	N = len ( arr )
	cntNumInRang ( arr , N )