Count cubes of size K inscribed in a cube of size N | Java implementation of the above approach ; Function to find the number of the cubes of the size K ; Stores the number of cubes ; Stores the number of cubes of size k ; Driver Code ; Size of the bigger cube ; Size of the smaller cube
class GFG { static int No_of_cubes ( int N , int K ) { int No = 0 ; No = ( N - K + 1 ) ; No = ( int ) Math . pow ( No , 3 ) ; return No ; } public static void main ( String [ ] args ) { int N = 5 ; int K = 2 ; System . out . print ( No_of_cubes ( N , K ) ) ; } }