Problem 59249. Compute the total length of lines between all vertices of a regular polygon
Write a function to compute the total length of between all vertices of a regular polygon inscribed in a unit circle. For example, a square in a unit circle would have side length of and each of the two diagonals would have a length of 2. Therefore, for the total length is . In the hexagon below, there are 6 lines of length 1 connecting adjacent points, 3 lines of length 2 connecting opposite points, and 6 lines of length connecting points two away; therefore, for , the total length is .
Solution Stats
Problem Comments
-
7 Comments
Show
4 older comments
Christian Schröder
on 3 Dec 2023
I'm having the same problem as William: all tests pass except for test 14. I'm inclined to blame the test rather than my code (famous last words, I know).
ChrisR
on 3 Dec 2023
OK, I reduced the number of terms in Test 14, and the three solutions submitted so far work.
Christian Schröder
on 4 Dec 2023
Thanks, Chris!
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
10323 Solvers
-
951 Solvers
-
Volume of a sphere given its surface area
151 Solvers
-
Moving average (variable kernel length)
127 Solvers
-
Sum the numbers on the main diagonal
588 Solvers
More from this Author291
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!