Given an integer N, the task is to find the largest even and odd N-digit numbers.
Input: N = 4
Even = 9998
Odd = 9999
Input: N = 2
Even = 98
Odd = 99
- Largest N-digit even number will be (10n) – 2 because the series for different values of N will be 8, 98, 998, 9998, …..
- Similarly, largest N-digit odd number will be (10n) – 1 for the series 9, 99, 999, 9999, …..
Below is the implementation of the above approach:
Even = 9998 Odd = 9999
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.
- Largest Even and Odd N-digit numbers of base B
- Smallest and Largest sum of two n-digit numbers
- Largest number in [2, 3, .. n] which is co-prime with numbers in [2, 3, .. m]
- Largest palindrome which is product of two n-digit numbers
- Largest and Smallest N-digit Octal Numbers
- Largest N digit number divisible by given three numbers
- Largest palindrome which is product of two N-digit numbers : Set 2
- Largest and Smallest N-digit Hexadecimal Numbers
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Largest number by which given 3 numbers should be divided such that they leaves same remainder
- Sum and product of k smallest and k largest prime numbers in the array
- Sum and product of k smallest and k largest composite numbers in the array
- Largest of two distinct numbers without using any conditional statements or operators
- Largest Even and Odd N-digit numbers in Octal Number System
- Count of triplets of numbers 1 to N such that middle element is always largest
- Find the length of largest subarray in which all elements are Autobiographical Numbers
- Sum of largest divisor of numbers upto N not divisible by given prime number P
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Fill the missing numbers in the array of N natural numbers such that arr[i] not equal to i
- Count of numbers upto M divisible by given Prime Numbers
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.
Improved By : ihritik