Count the number of rhombi possible inside a rectangle of given size | Java implementation of the approach ; Function to return the count of rhombi possible ; All possible diagonal lengths ; Update rhombi possible with the current diagonal lengths ; Return the total count of rhombi possible ; Driver code
import java . io . * ; class GFG { static int countRhombi ( int h , int w ) { int ct = 0 ; for ( int i = 2 ; i <= h ; i += 2 ) for ( int j = 2 ; j <= w ; j += 2 ) ct += ( h - i + 1 ) * ( w - j + 1 ) ; return ct ; } public static void main ( String [ ] args ) { int h = 2 , w = 2 ; System . out . println ( countRhombi ( h , w ) ) ; } }