Nth term where K + 1 th term is product of Kth term with difference of max and min digit of Kth term | C # implementation to find the value of the given function for the value ; 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
using System ; class GFG { static int MIN ( int n ) { int ans = 11 ; while ( n > 0 ) { ans = Math . Min ( ans , n % 10 ) ; n /= 10 ; } return ans ; } static int MAX ( int n ) { int ans = - 1 ; while ( n > 0 ) { ans = Math . Max ( ans , n % 10 ) ; n /= 10 ; } return ans ; } static void Find_value ( int n , int k ) { k -- ; int x = 0 ; int y = 0 ; while ( k -- > 0 ) { x = MIN ( n ) ; y = MAX ( n ) ; if ( y - x == 0 ) break ; n *= ( y - x ) ; } Console . Write ( n ) ; } public static void Main ( String [ ] args ) { int N = 487 , D = 5 ; Find_value ( N , D ) ; } }