Cumulative product of digits of all numbers in the given range | Java program to print the product of all numbers in range L and R ; Function to get product of digits ; Function to find the product of digits of all natural numbers in range L to R ; Iterate between L to R ; Driver Code
class GFG { static int getProduct ( int n ) { int product = 1 ; while ( n != 0 ) { product = product * ( n % 10 ) ; n = n / 10 ; } return product ; } static int productinRange ( int l , int r ) { if ( r - l > 9 ) return 0 ; else { int p = 1 ; for ( int i = l ; i <= r ; i ++ ) p *= getProduct ( i ) ; return p ; } } public static void main ( String [ ] args ) { int l = 11 , r = 15 ; System . out . print ( productinRange ( l , r ) + "NEW_LINE"); l = 1 ; r = 15 ; System . out . print ( productinRange ( l , r ) ) ; } }