Given a positive interger N and base B, the task is to find the largest N-digit numbers of Base B in decimal form.
Input: N = 2, B = 10
Input: N = 2, B = 5
Since there are B digits in base B, so with these digits we can create BN strings of length N. They represent the integers in range 0 to BN – 1
Therefore, the largest N-digits number of base B in decimal form is given by BN – 1.
Below is the implementation of the above approach:
Time Complexity: O(1)
Auxiliary Space: O(1)
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 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 Even and Odd N-digit numbers of base B
- Find the Nth digit from right in base B of the given number in Decimal base
- Largest number less than N with digit sum greater than the digit sum of N
- Given a number N in decimal base, find number of its digits in any base (base b)
- Largest K digit number divisible by X
- Largest and smallest digit of a number
- Largest even digit number not greater than N
- C++ Program for Largest K digit number divisible by X
- Largest N digit number divisible by given three numbers
- Smallest and Largest N-digit number starting and ending with N
- Queries for the smallest and the largest prime number of given digit
- Java Program for Largest K digit number divisible by X
- Largest Even and Odd N-digit numbers in Octal Number System
- Largest N digit Octal number which is a Perfect square
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Largest number less than N whose each digit is prime number
- Given a number N in decimal base, find the sum of digits in any base B
- Program to find the last digit of X in base Y
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.