summaryrefslogtreecommitdiff
path: root/sys/src/cmd/python/Demo/scripts/pi.py
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2021-06-14 00:00:37 +0000
committerOri Bernstein <ori@eigenstate.org>2021-06-14 00:00:37 +0000
commita73a964e51247ed169d322c725a3a18859f109a3 (patch)
tree3f752d117274d444bda44e85609aeac1acf313f3 /sys/src/cmd/python/Demo/scripts/pi.py
parente64efe273fcb921a61bf27d33b230c4e64fcd425 (diff)
python, hg: tow outside the environment.
they've served us well, and can ride off into the sunset.
Diffstat (limited to 'sys/src/cmd/python/Demo/scripts/pi.py')
-rwxr-xr-xsys/src/cmd/python/Demo/scripts/pi.py34
1 files changed, 0 insertions, 34 deletions
diff --git a/sys/src/cmd/python/Demo/scripts/pi.py b/sys/src/cmd/python/Demo/scripts/pi.py
deleted file mode 100755
index 9b242451a..000000000
--- a/sys/src/cmd/python/Demo/scripts/pi.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#! /usr/bin/env python
-
-# Print digits of pi forever.
-#
-# The algorithm, using Python's 'long' integers ("bignums"), works
-# with continued fractions, and was conceived by Lambert Meertens.
-#
-# See also the ABC Programmer's Handbook, by Geurts, Meertens & Pemberton,
-# published by Prentice-Hall (UK) Ltd., 1990.
-
-import sys
-
-def main():
- k, a, b, a1, b1 = 2L, 4L, 1L, 12L, 4L
- while 1:
- # Next approximation
- p, q, k = k*k, 2L*k+1L, k+1L
- a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
- # Print common digits
- d, d1 = a/b, a1/b1
- while d == d1:
- output(d)
- a, a1 = 10L*(a%b), 10L*(a1%b1)
- d, d1 = a/b, a1/b1
-
-def output(d):
- # Use write() to avoid spaces between the digits
- # Use str() to avoid the 'L'
- sys.stdout.write(str(d))
- # Flush so the output is seen immediately
- sys.stdout.flush()
-
-if __name__ == "__main__":
- main()