Nth term of a sequence formed by sum of current term with product of its largest and smallest digit | C # program for the above approach . ; Function to find integer ; Because 1 st integer is K itself ; Initialize min_d and max_d ; Updating min_d and max_d ; Break if min digit is 0 ; Driver code
using System ; class GFG { static int find ( int K , int N ) { N -- ; while ( N -- != 0 ) { int curr_term = K ; int min_d = 9 ; int max_d = 0 ; while ( curr_term > 0 ) { int r = curr_term % 10 ; min_d = Math . Min ( min_d , r ) ; max_d = Math . Max ( max_d , r ) ; curr_term = ( int ) ( curr_term / 10 ) ; } if ( min_d == 0 ) { break ; } K = K + min_d * max_d ; } return K ; } public static void Main ( ) { int K = 487 ; int N = 2 ; Console . Write ( find ( K , N ) ) ; } }