Number of cells in the Nth order figure | Java implementation of the approach ; Function to return the number of cells in the nth order figure of the given type ; Driver code
class GFG { static int cntCells ( int n ) { int cells = ( int ) Math . pow ( n , 2 ) + ( int ) Math . pow ( n - 1 , 2 ) ; return cells ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( cntCells ( n ) ) ; } }