Disclaimer: This is not homework, it is not for a class, and it is not for any kind of test.
I'm trying to improve my skills with creating algorithms to solve word problems.
I've been banging my head on this one and in the spirit of learning I would like help with a solution.
Please explain your thought process in coming up with a solution. I would like to discover what thoughts I am NOT having so that I can hopefully use that observation to improve my thought process.
Problem:
- The side of each square is one.
- The area of each square is one.
- Come up with a formula where given n, find the area of a polygon
- n can be any integer
Picture of the polygons.
n | area | thoughts about the formula |
---|---|---|
1 | 1 | each side is one, area is one |
2 | 5 | n -1 = 1. 1 square = 4 sides, each can attach a square, 4 squares, area = 4 + 1 |
3 | 13 | n-1 = 2, 2 squares = 8 sides, each can attach a square, 8 new squares + 5 old squares, area = 13 |
4 | 25 | n-1 = 3, 3 squares = 12 sides, each can attach a square, 12 new squares + 13 old squares, area = 25 |
The part that is driving me nuts is how given just n, to come up with the number of preexisting squares to add to the area generated by (n-1) x 4.
My intuition is that I may not be supposed to do that, but I can't think of how else to get the area of each progressively larger polygon given just n.
Any clues would be greatly appreciated.