Find the nth decimal of pi

05AB1E, 3 bytes

žs¤

Explained

žs   # push pi to N digits
  ¤  # get last digit

Try it online

Uses 1-based indexing.
Supports up to 100k digits.


Python 2, 66 bytes

n=input()+9
x=p=5L**7
while~-p:x=p/2*x/p+10**n;p-=2
print`x/5`[-9]

Input is taken from stdin.


Sample Usage

$ echo 10 | python pi-nth.py
8

$ echo 100 | python pi-nth.py
8

$ echo 1000 | python pi-nth.py
3

$ echo 10000 | python pi-nth.py
5

Bash + coreutils, 60 49 bytes

echo "scale=10100;4*a(1)"|bc -l|tr -d '\\\n'|cut -c$(($1+2))

bc -l<<<"scale=$1+9;4*a(1)-3"|tr -dc 0-9|cut -c$1

Improved by Dennis. Thanks!

The index is one-based.

Tags:

Pi

Math

Code Golf