3 ms·
It took me 6 minutes to code something that I think solves this, mainly spent on thinking about what the end condition of the loop should be.
by Jabbles 14y ago
It took me 6 minutes to code something that I think solves this, mainly spent on thinking about what the end condition of the loop should be.
- Chris_Newton 14y agoI remember very well the first time I tried a programming exercise like this. I probably spent 2 minutes writing the loop, and then I must have spent another 20 minutes wondering what I’d done wrong, until I realised that the sequence I’d been given really did converge that slowly. :-) In the spirit of helping anyone who’s at that stage now, if you’re running on a slow machine, I suggest you try this sequence instead: π² = 12( 1 - 1/2² + 1/3² - 1/4² + ... ) It converges much faster.