C# Shape Area
static long ShapeArea(long n)
{
return n > 1 ? ShapeArea(n - 1) + 4 * (n - 1) : 1;
}
This returns the area of the growing n-interesting polygon using the direct formula instead of building the shape.
static long ShapeArea(long n)
{
return n > 1 ? ShapeArea(n - 1) + 4 * (n - 1) : 1;
}
This returns the area of the growing n-interesting polygon using the direct formula instead of building the shape.