Given two integers L and R, the task is to find the cumulative product of digits (i.e. product of the product of digits) of all Natural numbers in the range L to R.
Input: L = 2, R = 5
2 * 3 * 4 * 5 = 120
Input: L = 11, R = 15
(1*1) * (1*2) * (1*3) * (1*4) * (1*5) = 1 * 2 * 3 * 4 * 5 = 120
To solve the problem mentioned above we have to observe that if:
- If the difference between L and R is greater than 9 then the product is 0 because there appears a digit 0 in every number after intervals of 9.
- Otherwise, We can find the product in a loop from L to R, the loop will run a maximum of 9 times.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Minimum digits to be removed to make either all digits or alternating digits same
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Count of numbers with all digits same in a given range
- Print all numbers in given range having digits in strictly increasing order
- Count all prime numbers in a given range whose sum of digits is also prime
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Cumulative frequency of count of each element in an unsorted array
- Find permutation array from the cumulative sum array
- Sum of product of proper divisors of all Numbers lying in range [L, R]
- Count numbers in range L-R that are divisible by all of its non-zero digits
- Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3
- Find all the possible numbers in a range that can be evenly divided by its digits
- Find the number in a range having maximum product of the digits
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Number of ways to obtain each numbers in range [1, b+c] by adding any two numbers in range [a, b] and [b, c]
- Count of numbers from range [L, R] that end with any of the given digits
- Numbers with a Fibonacci difference between Sum of digits at even and odd positions in a given range
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.