human
Count of all even numbers in the range [ L , R ] whose sum of digits is divisible by 3 | Function to return the sum of digits of x.
Function to return the count of required numbers.
If i is divisible by 2 and sum of digits of i is divisible by 3.
Return the required count.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count of all even numbers in the range [ L , R ] whose sum of digits is divisible by 3 and the other steps required.
 def sumOfDigits ( x ) :
	sum = 0
	while x != 0 :
		sum += x % 10
		x = x // 10
	return sum
def countNumbers ( l , r ) :
	count = 0
	for i in range ( l , r + 1 ) :
		if i % 2 == 0 and sumOfDigits ( i ) % 3 == 0 :
			count += 1
	return count
l = 1000 ; r = 6000
print ( countNumbers ( l , r ) )