human
Count all the numbers in a range with smallest factor as K | Function to check if k is a prime number or not.
Corner case.
Check from 2 to n - 1.
Function to check if a number is not divisible by any number between 2 and K - 1.
to check if the num is divisible by any numbers between 2 and k - 1.
if not divisible by any number between 2 and k - 1 but divisible by k.
Function to find count of numbers in range [ a , b ] with smallest factor as K.
a number can be divisible only by k and not by any number less than k only if k is a prime.
to check if a number has smallest factor as K.
Driver code"
How can the above be solved in Python?

Write me a code to count all the numbers in a range with smallest factor as K and the other steps required?
assistant
#Here is code to count all the numbers in a range with smallest factor as K and the other steps required.
 def isPrime ( k ) :
	if ( k <= 1 ) :
		return False
	for i in range ( 2 , k ) :
		if ( k % i == 0 ) :
			return false
	return True
def check ( num , k ) :
	flag = 1
	for i in range ( 2 , k ) :
		if ( num % i == 0 ) :
			flag = 0
	if ( flag == 1 ) :
		if ( num % k == 0 ) :
			return 1
		else :
			return 0
	else :
		return 0
def findCount ( a , b , k ) :
	count = 0
	if ( not isPrime ( k ) ) :
		return 0
	else :
		for i in range ( a , b + 1 ) :
			ans = check ( i , k )
			if ( ans == 1 ) :
				count += 1
			else :
				continue
	return count
if __name__ == " _ _ main _ _ " :
	a = 2020
	b = 6300
	k = 29
	print ( findCount ( a , b , k ) )