Given an integer N and base B, the task is to find the largest Even and Odd N-digit numbers of Base B in decimal form.
Input: N = 2, B = 5
Even = 24
Odd = 23
Largest Even Number of 2 digits in base 5 = 44 which is 24 in decimal form.
Largest Odd Number of 2 digits in base 5 = 43 which is 23 in decimal form.
Input: N = 2, B = 10
Even = 98
Odd = 99
To get the largest Even and Odd N-digits number of base B in decimal form is given by:
- If Base B is Even, then:
- Largest N-digit even number is (BN – 2).
- Largest N-digit odd number is (BN – 1).
- If Base B is Odd, then:
- Largest N-digit Even number is (BN – 1).
- Largest N-digit Odd number is (BN – 2).
Below is the implementation of the above approach:
Even Number = 24 Odd Number = 23
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.
- Given a number N in decimal base, find number of its digits in any base (base b)
- C++ program to find all numbers less than n, which are palindromic in base 10 and base 2.
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Check if a number has an odd count of odd divisors and even count of even divisors
- Check if the number is even or odd whose digits and base (radix) is given
- Add two integers of different base and represent sum in smaller base of the two
- Check if a N base number is Even or Odd
- Find the Nth digit from right in base B of the given number in Decimal base
- Given a number N in decimal base, find the sum of digits in any base B
- Largest Even and Odd N-digit numbers
- Largest Even and Odd N-digit numbers in Octal Number System
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Largest value of x such that axx is N-digit number of base b
- Find the Largest N digit perfect square number in Base B
- Largest N digit number in Base B
- Sum of elements in range L-R where first half and second half is filled with odd and even numbers
- Generate an array of given size with equal count and sum of odd and even numbers
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1
- Print all n-digit numbers with absolute difference between sum of even and odd digits is 1
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.