human
Numbers in a Range with given Digital Root | Function to return the count of required numbers.
Count of numbers present in given range.
Number of groups of 9 elements starting from L.
Left over elements not covered in factor 9.
One Number in each group of 9.
To check if any number in rem satisfy the property.
Driver code"
Solution in Python:
 ... Give me a code to numbers in a Range with given Digital Root and the other steps required?
assistant
#Here is code to numbers in a Range with given Digital Root and the other steps required.
 def countNumbers ( L , R , K ) :
	if ( K == 9 ) :
		K = 0
	totalnumbers = R - L + 1
	factor9 = totalnumbers // 9
	rem = totalnumbers % 9
	ans = factor9
	for i in range ( R , R - rem , - 1 ) :
		rem1 = i % 9
		if ( rem1 == K ) :
			ans += 1
	return ans
L = 10
R = 22
K = 3
print ( countNumbers ( L , R , K ) )