If you can explain to me, not only solve it, it will really be incredible.
FIRST: It's an exercise that my teacher gave me, it really does not have any value in my grades, but I'm trying to solve it, and I can't when I do the tests says
Input: n: 3 Output: 10 Expected Output: 13 Console Output: Empty
Here is the question:
Below we will define an n-interesting polygon. Your task is to find the area of a polygon for a given n.
A 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.
You can do it in the simplest way. I set down calculations and found that for:
Then I figured out formula : n^2 + (n-1)*(n-1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With