This question already has an answer here:
- Find the nth decimal of pi 18 answers
Given an input
n, calculate the n-th decimal digit of pi
- 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.
nvalues 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.piin 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.
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.