Given an integer N, the task is to find the product of N with its largest odd digit. If there is no odd digit in N then print -1 as the output.
The largest odd digit in 12345 is 5 and 12345 * 5 = 61725
Approach: Traverse through all the digits of N and set maxOdd = -1, if current digit is odd and > maxOdd then update maxOdd = current digit.
If in the end, maxOdd = -1 then print -1 else print N * maxOdd.
Below is the implementation of the above approach:
- Largest palindrome which is product of two n-digit numbers
- Largest number less than N with digit sum greater than the digit sum of N
- Digit - Product - Sequence
- First digit in product of an array of numbers
- Largest Even and Odd N-digit numbers
- Last digit of Product of two Large or Small numbers (a * b)
- Check if all sub-numbers have distinct Digit product
- Maximum number with same digit factorial product
- Largest even digit number not greater than N
- Largest K digit number divisible by X
- Largest and smallest digit of a number
- Smallest and Largest sum of two n-digit numbers
- Check if the product of digit sum and its reverse equals the number or not
- Largest N digit number divisible by given three numbers
- Smallest and Largest N-digit perfect cubes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.