Problem 953. Pi Estimate 1
Solution Stats
Problem Comments
-
17 Comments
I'll have to say that the checking algorithm is very poorly written. Using isequal instead of an absolute difference with a permitted tolerance check is straight out flawed for me. And after repeating the calculations with both Python and MATLAB. I get an estimate of 3.2323.. for a series of 10 elements (nMax = 10). I wonder how the problem setters arrived at an estimate of 3.04... something. I can't remember the exact value that was used for that test.
So in running this summation through my ti-nspire for 10 iterations, I get an estimate of 3.232323... However, test 1 asserts that this should actually be 3.041840. The code I wrote also returns 3.232323, because it uses the Leibniz formula to estimate pi using the specified number of iterations "nMax". Either I am completely missing something or the author is unaware of what values a correct solution should actually be returning.
Like Sam, my code does not match the 'correct solutions.' As some previous comments suggested, I set my format to long and rounded to six digits.
nMax = 10, my estimate is 3.232316000000000
nMax = 1000, my estimate is 3.142592000000000
nMax = 1e6, my estimate is 3.141594000000000
Solution Comments
Show commentsGroup

Project Euler II
- 12 Problems
- 51 Finishers
- Sums of cubes and squares of sums
- Sum of big primes without primes
- Project Euler: Problem 11, Largest product in a grid
- Highly divisible triangular number (inspired by Project Euler 12)
- Divisors for big integer
- Large Sum (inspired by Project Euler 13)
- Longest Collatz Sequence
- Project Euler: Problem 16, Sums of Digits of Powers of Two
- Project Euler: Problem 18, Maximum path sum I
- Recurring Cycle Length (Inspired by Project Euler Problem 26)
- Numbers spiral diagonals (Part 1)
- Numbers spiral diagonals (Part 2)
Problem Recent Solvers1215
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!