25
4
Write a program to calculate the first 500 digits of pi, meeting the rules below:
- It must be less than 500 characters in length.
- It cannot include "pi", "math.pi" or similar pi constants, nor may it call a library function to calculate pi.
- It may not use the digits "3", "1" and "4" consecutively.
- It must execute in a reasonable time (under 1 minute) on a modern computer.
The shortest program wins.
1Can we use an HTTP library to download a "digits of pi" website? ;-) – dan04 – 2011-02-17T05:47:11.917
Came here hoping to get something nice and concise for generating arbitrary length approximations of pi in python... unfortunately @Soulman's python solution is apparently tuned for 500 digits; replacing 500 with 1000 gives an incorrect answer. I wonder if there is a good way of phrasing an alternative challenge that would produce a nice short function that is generally useful for generating an arbitrary number of digits? – Don Hatch – 2016-04-28T08:21:33.813
I think this question would have been much better off restricting the programming languages accepted. – Tyzoid – 2014-01-04T05:32:44.797
Related mathematics post: https://math.stackexchange.com/q/1189820/272831
– Simply Beautiful Art – 2017-09-18T18:42:05.163It may not use the digits "3", "1" and "4" consecutively
I assume that you can do"3"+".14"
orreverse(<500 digits of pi in reverse>)
. – Naruyoko – 2019-10-03T17:19:20.663To check if your digits are correct: http://www.eveandersson.com/pi/digits/
– Nellius – 2011-02-04T15:07:35.437Are we allowed to print more than 500 digits with loss of accuracy after first 500? – Alexandru – 2011-02-04T15:27:05.093
@Alexandru, I suppose so but I would prefer to see it truncated. – Thomas O – 2011-02-04T17:16:38.933
@Joey no library functions TO CALCULATE PI - I would assume you can use anything from the libraries except the PI constant / function. – Aurel Bílý – 2011-02-05T21:27:38.970