There is no tutorial about this specific ploblem. You need learn other concepts like recursion and loops.
This function shapeArea is not important. It's used to measure the amount of time.
Relevant things on this exercise is x.loopShapeArea, x.recursionShapeArea and x.mathShapeArea. Three of them solves the problem, but math is more efficient than others.
But where did you get the 4 from & multiplying it ?
For example when I can recite something for 60 times in a min so if i recite for 100 mins i just do 60 * 100 to find out how many times I recite a line.
What was ur reasoning behind using the number 4 ? I am not clear on how I would go on solving this on my own. @
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.
There is no tutorial about this specific ploblem. You need learn other concepts like recursion and loops.
This function
shapeArea
is not important. It's used to measure the amount of time.Relevant things on this exercise is
x.loopShapeArea
,x.recursionShapeArea
andx.mathShapeArea
. Three of them solves the problem, but math is more efficient than others.But where did you get the 4 from & multiplying it ?
For example when I can recite something for 60 times in a min so if i recite for 100 mins i just do 60 * 100 to find out how many times I recite a line.
What was ur reasoning behind using the number 4 ? I am not clear on how I would go on solving this on my own. @
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.