[1] https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%9...
I don't fully comprehend the code still, but the SCALE parameter suggest that it handles the elements of the array as a fixed point representation of real numbers. I wonder if it's correct for large number of digits.
def nthHexDigitOfPI(n):
return 4/(8*n+1) - 2/(8*n+4) - 1/(8*n+5) - 1/(8*n+6)Simon Plouffe did it, years ago, with no help from Google.
http://plouffe.fr/Simon%20Plouffe.htm
https://en.m.wikipedia.org/wiki/Bailey–Borwein–Plouffe_formu...
For the lay-programmer, e.g., “any person or people”, everything on that list is an exercise in learning how the problem was solved by someone else, and writing the code for it. The idea is to learn, not to invent the solution from scratch without help. The way to code the spigot algorithm for pi is to lookup the formula, understand it, figure out how to deal with precision and numeric base conversion, and write the code. Pretty much anyone can do that.
Where did I imply it? The site being discussed uses “anyone” in the sense “any person”. I questioned that, but didn’t realize that I used the word in the second meaning the second time I used it.
”The way to code the spigot algorithm for pi is to lookup the formula, understand it, figure out how to deal with precision and numeric base conversion, and write the code. Pretty much anyone can do that.”
That, we disagree about. We live in a world where “Fizz-Buzz” is a thing, so I’m not that optimistic that anybody can do what you describe.
It seems weird you asked that since I just said where, explicitly. This part of the conversation feels tedious and unnecessary. The precise meaning of “anyone” being used by you & the article is pretty irrelevant.
> I’m not that optimistic that anybody can do what you describe.
You’re right, I disagree. I’m sorry for your pessimism. My children can and do lookup formulas on Wikipedia and code them, it’s not hard, if you care to try. I understand if you feel it is too difficult. FWIW, that’s precisely what the post we’re commenting on is aiming to help curious and optimistic people with. Maybe consider how it might be able to help your situation rather than criticize? Everyone can do fizzbuzz too, it’s existence doesn’t prove anything.
P/(2*r) > Pi > P/(2*R)
Once you have approximated it, returning a string with the first x digits is trivial
Easily solvable if you set that limit low and cheat. Just put a string representation of pi in the program, and chop it off at the requested length:
If you don’t cheat or if ”Keep a limit to how far the program will go” doesn’t mean what I read in it, I have my doubts anyone can write that program, even with support from Google.