VOOZH about

URL: https://www.geeksforgeeks.org/computer-science-fundamentals/area-of-squares-formed-by-joining-mid-points-repeatedly/

⇱ Area of squares formed by joining mid points repeatedly - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Area of squares formed by joining mid points repeatedly

Last Updated : 12 Oct, 2022

Given a square having a side of length L. Another square form inside the first square by joining midpoint of the side of the first square. Now 3rd square is form inside 2nd one by joining midpoints of the side of the 2nd square and so on. 
You have 10 squares inside each other. and you are given side length of largest square. you have to find the area of these 10 squares.

Examples: 

Input : L = 5, n = 10
Output :49.9512

Input : L = 2, n = 2
Output :7.99219

This article can be understand using diagram that depicts the whole problem. 
 

👁 Image


From the diagram- 
Area of outermost square will be given by L^2. 
Area of 2nd square-As length of 2nd square can be calculate using Pythagoras theorem., side for this square will be \\ 


 

Area of 3rd square- 
Similarly area of third square can be calculated, we get 



 

Area of 4th square- 
Similarly area of forth square can be calculated, we get 



 

Hence this form Geometric progression, having first term as L^2 and common ratio = 1/2. 


 

Now we have to find sum of first n terms of this GP. 


 


Output: 
7.99219

 

Time Complexity: O(1)
Auxiliary Space: O(1)

Comment