Nth term where K + 1 th term is product of Kth term with difference of max and min digit of Kth term | Function to find minimum digit in the decimal representation of N ; Loop to find the minimum digit in the number ; Function to find maximum digit in the decimal representation of N ; Loop to find the maximum digit in the number ; Function to find the value of the given function ; Loop to compute the values of the given number ; Driver Code ; Function Call
def MIN ( n ) : NEW_LINE INDENT ans = 11 NEW_LINE while n : NEW_LINE INDENT ans = min ( ans , n % 10 ) NEW_LINE n //= 10 NEW_LINE DEDENT return ans NEW_LINE DEDENT def MAX ( n ) : NEW_LINE INDENT ans = - 1 NEW_LINE while n : NEW_LINE INDENT ans = max ( ans , n % 10 ) NEW_LINE n //= 10 NEW_LINE DEDENT return ans NEW_LINE DEDENT def Find_value ( n , k ) : NEW_LINE INDENT k -= 1 NEW_LINE ( x , y ) = ( 0 , 0 ) NEW_LINE while k : NEW_LINE INDENT k -= 1 NEW_LINE x = MIN ( n ) NEW_LINE y = MAX ( n ) NEW_LINE if ( ( y - x ) == 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT n *= ( y - x ) NEW_LINE DEDENT print ( n , end = ' ▁ ' ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT ( N , D ) = ( 487 , 5 ) NEW_LINE Find_value ( N , D ) NEW_LINE DEDENT