human
What is a code to check if a number S can be made divisible by D by repeatedly adding the remainder to S and the other steps required given the following:
Check if a number S can be made divisible by D by repeatedly adding the remainder to S | Function to check if S is divisible by D while changing S to ( S + S % D ).
V ( 0 ) = S % D.
Stores the encountered values.
V ( i ) = ( V ( i - 1 ) + V ( i - 1 ) % D ) % D.
Check if the value has already been encountered.
Edge Case.
Otherwise , insert it into the hashmap.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if a number S can be made divisible by D by repeatedly adding the remainder to S and the other steps required.
 def isDivisibleByDivisor ( S , D ) :
	S %= D
	hashMap = set ( )
	hashMap . add ( S )
	for i in range ( D + 1 ) :
		S += ( S % D )
		S %= D
		if ( S in hashMap ) :
			if ( S == 0 ) :
				return " Yes "
			return " No "
		else :
			hashMap . add ( S )
	return " Yes "
if __name__ == ' _ _ main _ _ ' :
	S = 3
	D = 6
	print ( isDivisibleByDivisor ( S , D ) )