Go Shape Area
func shapeArea(n int) int {
if n > 1 {
return shapeArea(n-1) + 4*(n-1)
}
return 1
}
This returns the area of the growing n-interesting polygon using the direct formula instead of building the shape.
func shapeArea(n int) int {
if n > 1 {
return shapeArea(n-1) + 4*(n-1)
}
return 1
}
This returns the area of the growing n-interesting polygon using the direct formula instead of building the shape.