text: Number of cards needed build a House of Cards of a given level N | C ++ implementation of the above approach ; Function to find number of cards needed ; Driver Code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int noOfCards ( int n ) { return n * ( 3 * n + 1 ) / 2 ; } int main ( ) { int n = 3 ; cout << noOfCards ( n ) << " , ▁ " ; return 0 ; }