Problem 59249. Compute the total length of lines between all vertices of a regular polygon
Solution Stats
Problem Comments
-
7 Comments
The test suite seems suspicious to me. The length of the diagonals will add up to n, and the length of the edges will never be more than 2*pi*r = 6.28. Where are all the big values coming from?
"Diagonals" was confusing, so I changed the wording and added another example.
Oh, I see. The example of the square led me to believe that "diagonal" meant "diameter". Thanks for the clarification!
I am having precision problems with the first and third assert()'s in test 14. The relative precision on the first is about 1e-10 and it is getting a sum that is different by about 3 units. For the third, the error is much worse because if any of the elements of a() are off by even 1 unit, they don't trigger the isprime() and don''t get included in the sum.
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).
OK, I reduced the number of terms in Test 14, and the three solutions submitted so far work.
Thanks, Chris!
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
41999 Solvers
-
Remove any row in which a NaN appears
8587 Solvers
-
Count from 0 to N^M in base N.
235 Solvers
-
Back to basics 8 - Matrix Diagonals
924 Solvers
-
(Linear) Recurrence Equations - Generalised Fibonacci-like sequences
314 Solvers
More from this Author279
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!