Count numbers upto N which are both perfect square and perfect cube | Java implementation of the above approach ; Function to return required count ; Driver code ; function call to print required answer
public class GFG { static int SquareCube ( long N ) { int cnt = 0 , i = 1 ; while ( ( int ) ( Math . pow ( i , 6 ) ) <= N ) { ++ cnt ; ++ i ; } return cnt ; } public static void main ( String [ ] args ) { long N = 100000 ; System . out . println ( SquareCube ( N ) ) ; } }