Number of elements with even factors in the given range | C ++ implementation of the above approach ; Function to count the perfect squares ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countOddSquares ( int n , int m ) { return ( int ) pow ( m , 0.5 ) - ( int ) pow ( n - 1 , 0.5 ) ; } int main ( ) { int n = 5 , m = 100 ; cout << " Count ▁ is ▁ " << ( m - n + 1 ) - countOddSquares ( n , m ) ; return 0 ; }