Given two integers N and B, the task is to find the largest N digit numbers of Base B which is a perfect square.
Input: N = 2, B = 10
81 is the largest 2-digit perfect square in base 10.
Input: N = 1, B = 8
4 is the largest 1 digit Octal number which is also a perfect square.
Approach: The largest number N in base B is given by . So if we find the square root of this number in integer form and then we have to again do its square then it will be the largest perfect square of N digits which is given by the formula: .
Below is the implementation of the above approach:
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 N digit Octal number which is a Perfect square
- Smallest N digit number whose sum of square of digits is a Perfect Square
- Largest value of x such that axx is N-digit number of base b
- Largest N digit number in Base B
- Find the Nth digit from right in base B of the given number in Decimal base
- Largest number that is not a perfect square
- Largest factor of a given number which is a perfect square
- Largest perfect square number in an Array
- Find smallest perfect square number A such that N + A is also a perfect square number
- Largest Divisor of a Number not divisible by a perfect square
- Number of times the largest perfect square number can be subtracted from N
- Largest Even and Odd N-digit numbers of base B
- Find the Next perfect square greater than a given number
- Find minimum number to be divided to make a number a perfect square
- Array range queries to find the number of perfect square elements with updates
- Smallest and Largest N-digit perfect squares
- Smallest and Largest N-digit perfect cubes
- Given a number N in decimal base, find number of its digits in any base (base b)
- Check if a number is perfect square without finding square root
- 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 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.