Forming triangles using points on a square | C # implementation of the above approach ; Function to return the count of possible triangles ; Driver code
using System ; class GFG { static int noOfTriangles ( int n ) { int y = 4 * n ; return ( ( y * ( y - 2 ) * ( y - 1 ) ) - ( 4 * n * ( n - 2 ) * ( n - 1 ) ) ) / 6 ; } public static void Main ( String [ ] args ) { int n = 1 ; Console . WriteLine ( noOfTriangles ( n ) ) ; } }