text: Number of cards needed build a House of Cards of a given level N | Java implementation of the above approach ; Function to find number of cards needed ; Driver Code
code: import java . lang . * ; class GFG { public static int noOfCards ( int n ) { return n * ( 3 * n + 1 ) / 2 ; } public static void main ( String args [ ] ) { int n = 3 ; System . out . print ( noOfCards ( n ) ) ; } }