Number of elements with even factors in the given range | Java implementation of the above approach ; Function to count the perfect squares ; Driver code
import java . io . * ; class GFG { static int countOddSquares ( int n , int m ) { return ( int ) Math . pow ( m , 0.5 ) - ( int ) Math . pow ( n - 1 , 0.5 ) ; } public static void main ( String [ ] args ) { int n = 5 , m = 100 ; System . out . println ( " Count ▁ is ▁ " + ( ( m - n + 1 ) - countOddSquares ( n , m ) ) ) ; } }