Find maximum product of digits among numbers less than or equal to N | Java implementation of the approach ; Function that returns the maximum product of digits among numbers less than or equal to N ; Driver code
import java . io . * ; class GFG { static int maxProd ( int N ) { if ( N == 0 ) return 1 ; if ( N < 10 ) return N ; return Math . max ( maxProd ( N / 10 ) * ( N % 10 ) , maxProd ( N / 10 - 1 ) * 9 ) ; } public static void main ( String [ ] args ) { int N = 390 ; System . out . println ( maxProd ( N ) ) ; } }