human
What is a code to number formed by adding product of its max and min digit K times and the other steps required given the following:
Number formed by adding product of its max and min digit K times | Function to find the formed number.
K -= 1 M ( 1 ) = N.
Check if minimum digit is 0.
Function that returns the product of maximum and minimum digit of N number ..
Find the last digit ..
Moves to next digit.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to number formed by adding product of its max and min digit K times and the other steps required.
 def formed_no ( N , K ) :
	if ( K == 1 ) :
		return N
	answer = N
	while ( K != 0 ) :
		a_current = prod_of_max_min ( answer )
		if ( a_current == 0 ) :
			break
		answer += a_current
		K -= 1
	return answer
def prod_of_max_min ( n ) :
	largest = 0
	smallest = 10
	while ( n != 0 ) :
		r = n % 10
		largest = max ( r , largest )
		smallest = min ( r , smallest )
		n = n // 10
	return largest * smallest
if __name__ == " _ _ main _ _ " :
	N = 487
	K = 100000000
	print ( formed_no ( N , K ) )