Count of perfect squares of given length | Java Program to count perfect squares of given length ; Function to return the count of n digit perfect squares ; Driver code
class GFG { static int countSquares ( int n ) { int r = ( int ) Math . ceil ( Math . sqrt ( Math . pow ( 10 , n ) ) ) ; int l = ( int ) Math . ceil ( Math . sqrt ( Math . pow ( 10 , n - 1 ) ) ) ; return r - l ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( countSquares ( n ) ) ; } }