From 3ce67cc1afb5daa913a99be6828fa0dc5743eece Mon Sep 17 00:00:00 2001 From: j Date: Wed, 4 Jan 2017 18:29:24 +0100 Subject: [PATCH] add pi --- pi.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pi.py diff --git a/pi.py b/pi.py new file mode 100644 index 0000000..7b3ebd1 --- /dev/null +++ b/pi.py @@ -0,0 +1,18 @@ +from mpmath import mp +mp.dps = 10000 +PI = str(mp.pi).replace('.', '') + +class random(object): + PI = str(mp.pi).replace('.', '') + + def __init__(self, offset=0): + self.numbers = list(map(int, self.PI[offset:])) + + def __call__(self): + if not self.numbers: + offset = mp.dps + mp.dps += 1000 + self.PI = str(mp.pi).replace('.', '') + self.numbers = list(map(int, self.PI[offset:])) + return self.numbers.pop(0) +