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 Solvers7
Suggested Problems
- 
         Get the area codes from a list of phone numbers 1068 Solvers 
- 
         
         155 Solvers 
- 
         
         388 Solvers 
- 
         Removing rows from a matrix is easy - but what about inserting rows? 247 Solvers 
- 
         Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92) 239 Solvers 
More from this Author314
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!