human
Program to find count of numbers having odd number of divisors in given range | Function to return the count of divisors of a number.
Count the powers of the current prime i which divides a.
Update the count of divisors.
Reset the count.
If the remaining a is prime then a ^ 1 will be one of its prime factors.
Function to count numbers having odd number of divisors in range [ A , B ].
To store the count of elements having odd number of divisors.
Iterate from a to b and find the count of their divisors.
To store the count of divisors of i.
If the divisor count of i is odd.
Driver code"
How can the above be solved in Python?
 ... Write me a code to program to find count of numbers having odd number of divisors in given range and the other steps required?
assistant
#Here is code to program to find count of numbers having odd number of divisors in given range and the other steps required.
 def divisor ( a ) :
	div = 1 ;
	count = 0 ;
	for i in range ( 2 , int ( pow ( a , 1 / 2 ) ) + 1 ) :
		while ( a % i == 0 ) :
			count += 1 ;
			a = a / i ;
		div = div * ( count + 1 ) ;
		count = 0 ;
	if ( a > 1 ) :
		div = div * ( 2 ) ;
	return div ;
def OddDivCount ( a , b ) :
	res = 0 ;
	for i in range ( a , b + 1 ) :
		divCount = divisor ( i ) ;
		if ( divCount % 2 ) :
			res += 1 ;
	return res ;
if __name__ == ' _ _ main _ _ ' :
	a , b = 1 , 10 ;
	print ( OddDivCount ( a , b ) ) ;