Given a number N, the task is to print the maximum between the sum and multiplication of the digits of the given number until the number is reduced to a single digit.
Note: Sum and multiplication of digits to be done until the number is reduced to a single digit.
Let’s take an example where N = 19,
19 breaks into 1+9=10 then 10 breaks into 1+0=1. 1 is a single digit sum.
Also, 19 breaks into 1*9 = 9. 9 is a single digit multiplication.
So, output is 9 i.e. maximum of 9 and 1.
Input: N = 631 Output: 8 Input: 110 Output: 2
- Check if a number is less than 10 then sum and product will be the same. So, return that number.
- Find the sum of digits repeatedly using Method 2 of Finding sum of digits of a number until sum becomes single digit.
- And, Find the product of digits repeatedly using Method 1 of Finding sum of digits of a number until sum becomes single digit.
- Return maximum of both.
Below is the implementation of above approach:
- Numbers less than N that are perfect cubes and the sum of their digits reduced to a single digit is 1
- Finding sum of digits of a number until sum becomes single digit
- Check whether a number can be expressed as a product of single digit numbers
- Maximum number with same digit factorial product
- Sum of Digits in a^n till a single digit
- Maximum sum and product of the M consecutive digits in a number
- Find the number in a range having maximum product of the digits
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Count positive integers with 0 as a digit and maximum 'd' digits
- Product of given N fractions in reduced form
- Number of times a number can be replaced by the sum of its digits until it only contains one digit
- Check if the product of digit sum and its reverse equals the number or not
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1
- Number of digits in the product of two numbers
- Smallest number k such that the product of digits of k is equal to n