human
Count of distinct integers belonging to first N terms of at least one of given GPs | Function to find the count of distinct integers that belong to the first N terms of at least one of them is GP.
Stores the integers that occur in GPs in a set data - structure.
Stores the current integer of the first GP.
Iterate first N terms of first GP.
Insert the ith term of GP in S.
Stores the current integer of the second GP.
Iterate first N terms of second GP.
Return Answer.
Driver Code"
How can the above be solved in Python?

What is a code to count of distinct integers belonging to first N terms of at least one of given GPs and the other steps required?
assistant
#Here is code to count of distinct integers belonging to first N terms of at least one of given GPs and the other steps required.
 def UniqueGeometricTerms ( N , a1 , r1 , a2 , r2 ) :
	S = set ( )
	p1 = a1
	for i in range ( N ) :
		S . add ( p1 )
		p1 = ( p1 * r1 )
	p2 = a2
	for i in range ( N ) :
		S . add ( p2 )
		p2 = ( p2 * r2 )
	return len ( S )
if __name__ == ' _ _ main _ _ ' :
	N = 5
	a1 = 3
	r1 = 2
	a2 = 2
	r2 = 3
	print ( UniqueGeometricTerms ( N , a1 , r1 , a2 , r2 ) )