I'm using a technic learned in a subject Numerical Methods. You need reproduce step by steep and try to find something familiar between each interaction.
A square have 4 sides, that's why you need multiply the value by four.
But each side merge a point with other in the other side (red circle), you can't count both. That's why yo need subtract 4, one for each corner.
That's how I found this formula: n * 4 - 4
On first and second iteration is difficult to see it... but next iterations can give you an idea about the solution.
Hope it helps.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm using a technic learned in a subject Numerical Methods. You need reproduce step by steep and try to find something familiar between each interaction.
A square have 4 sides, that's why you need multiply the value by four.
But each side merge a point with other in the other side (red circle), you can't count both. That's why yo need subtract 4, one for each corner.
That's how I found this formula:
n * 4 - 4
On first and second iteration is difficult to see it... but next iterations can give you an idea about the solution.
Hope it helps.