Count numbers upto N which are both perfect square and perfect cube | C ++ implementation of the above approach ; Function to return required count ; Driver code ; function call to print required answer
#include <bits/stdc++.h> NEW_LINE using namespace std ; int SquareCube ( long long int N ) { int cnt = 0 , i = 1 ; while ( int ( pow ( i , 6 ) ) <= N ) { ++ cnt ; ++ i ; } return cnt ; } int main ( ) { long long int N = 100000 ; cout << SquareCube ( N ) ; return 0 ; }