human
Find the Nth term divisible by a or b or c | Function to return gcd of a and b.
Function to return the lcm of a and b.
Function to return the count of numbers from 1 to num which are divisible by a , b or c.
Calculate number of terms divisible by a and by b and by c then , remove the terms which is are divisible by both a and b , both b and c , both c and a and then add which are divisible by a and b and c.
Function to find the nth term divisible by a , b or c by using binary search.
Set low to 1 and high to max ( a , b , c ) * n.
If the current term is less than n then we need to increase low to mid + 1.
If current term is greater than equal to n then high = mid.
Driver code"
Solution in Python:
 ... Give me a code to find the Nth term divisible by a or b or c and the other steps required?
assistant
#Here is code to find the Nth term divisible by a or b or c and the other steps required.
 def gcd ( a , b ) :
	if ( a == 0 ) :
		return b
	return gcd ( b % a , a )
def lcm ( a , b ) :
	return ( ( a * b ) // gcd ( a , b ) )
def divTermCount ( a , b , c , num ) :
	return ( ( num // a ) + ( num // b ) + ( num // c ) - ( num // lcm ( a , b ) ) - ( num // lcm ( b , c ) ) - ( num // lcm ( a , c ) ) + ( num // lcm ( a , lcm ( b , c ) ) ) )
def findNthTerm ( a , b , c , n ) :
	low = 1
	high = 10 ** 9
	mid = 0
	while ( low < high ) :
		mid = low + ( high - low ) // 2
		if ( divTermCount ( a , b , c , mid ) < n ) :
			low = mid + 1
		else :
			high = mid
	return low
a = 2
b = 3
c = 5
n = 10
print ( findNthTerm ( a , b , c , n ) )