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
- Largest Even and Odd N-digit numbers
- First digit in product of an array of numbers
- Largest even digit number not greater than N
- Smallest and Largest sum of two n-digit numbers
- Largest K digit number divisible by X
- Largest and smallest digit of a number
- Check if all sub-numbers have distinct Digit product
- Last digit of Product of two Large or Small numbers (a * b)
- Maximum number with same digit factorial product
- Smallest and Largest N-digit perfect cubes
- Smallest and Largest N-digit perfect squares
- C++ Program for Largest K digit number divisible by X
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.