7
2
Task
Given an input n
, calculate the n-th decimal digit of pi
Rules
- Answer can be a full program or a function.
- Input must be taken from stdin or from function arguments.
- Output must be either sent to stdout, the return value of a function, or written to a file.
- all
n
values between 0 and 20000 must be supported (can be between 1 and 20001 for 1-indexed languages). - Built-ins to calculate pi cannot be used. This includes pi constants (e.g.
math.pi
in Python) and built-in functions that return either the value of pi, or the n-th digit of pi. This means that an algorithm which calculates pi, or the n-th digit of pi must be implemented in your answer. - Digits must be calculated at runtime.
First digit (0-th or 1-th, depending on the language) is 3.
This is code-golf, so shortest code in bytes wins.
EDIT:
This is not a duplicate of 'Find the n-th decimal of pi', since that challenge allowed built-ins. This one is focused around actually implementing an algorithm to find the digits, rather than relying on built-ins.
The ban of built ins probably makes this different enough. – Jonathan Allan – 2016-10-25T11:34:52.767
6linking for the sake of completeness. In my opinion it's a dupe, because a lot of those answers can be copy pasted to this challenge. But not voting to close just yet. – Bassdrop Cumberwubwubwub – 2016-10-25T12:21:22.423
base16 allowed? – dwana – 2016-10-25T12:31:14.557
@dwana No, it has to be in base10 – penalosa – 2016-10-25T12:32:11.660
1This is a completely different challenge without the use of builtins. From what I can see all of the answers to the other question are using builtins and don't apply here. – cleblanc – 2016-10-25T14:11:48.097
2@cleblanc, it seems to me that five of the (undeleted) answers to the other question use series expansions such as the Leibniz series, and one uses an built-in for arctan which isn't technically in violation of the spec of this question. That makes 6 out of 13 answers which could be copied across unmodified. – Peter Taylor – 2016-10-25T15:21:36.353