Given a number N. The task is to find the largest and the smallest digit of the number.
Input : N = 2346
Output : 6 2
6 is the largest digit and 2 is samllest
Input : N = 5
Output : 5 5
Approach: An efficient approach is to find all digits in the given number and find the largest and the smallest digit.
- Queries for the smallest and the largest prime number of given digit
- Smallest and Largest sum of two n-digit numbers
- Smallest and Largest N-digit perfect squares
- Smallest and Largest N-digit perfect cubes
- Largest number less than N with digit sum greater than the digit sum of N
- Smallest K digit number divisible by X
- Smallest N digit number which is a multiple of 5
- Largest even digit number not greater than N
- Largest K digit number divisible by X
- Smallest n digit number divisible by given three numbers
- C++ Program for Smallest K digit number divisible by X
- Largest N digit number divisible by given three numbers
- C++ Program for Largest K digit number divisible by X
- Smallest N digit number which is a perfect fourth power
- Check if the first and last digit of the smallest number forms a prime
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.