Sunday, April 30, 2017

codefight arcade level2 shapeArea

Below we will define an n-interesting polygon. Your task is to find the area of a polygon for a given n.
1-interesting polygon is just a square with a side of length 1. An n-interesting polygon is obtained by taking the n - 1-interesting polygon and appending 1-interesting polygons to its rim, side by side. You can see the 1-, 2-, 3- and 4-interesting polygons in the picture below.

my solution is 

F(1) = 1;
F(n) = F(n-1) + 4(n-1)

Easy 

link
 https://codefights.com/arcade/intro/level-2/yuGuHvcCaFCKk56rJ

No comments:

Post a Comment