human
What is a code to count number of digits after decimal on dividing a number and the other steps required given the following:
Count number of digits after decimal on dividing a number | Python3 program to count digits after dot when a number is divided by another ..
ans = 0 Initialize result.
calculating remainder.
if this remainder appeared before then the numbers are irrational and would not converge to a solution the digits after decimal will be infinite.
Driver Code"
Solution in Python:
assistant
#Here is code to count number of digits after decimal on dividing a number and the other steps required.
 def count ( x , y ) :
	m = dict ( )
	while x % y != 0 :
		x %= y
		ans += 1
		if x in m :
			return - 1
		m [ x ] = 1
		x *= 10
	return ans
if __name__ == " _ _ main _ _ " :
	res = count ( 1 , 2 )
	print ( " INF " ) if res == - 1 else print ( res )
	res = count ( 5 , 3 )
	print ( " INF " ) if res == - 1 else print ( res )
	res = count ( 3 , 5 )
	print ( " INF " ) if res == - 1 else print ( res )