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.