Changeset 391 for python/trunk/Demo/scripts/pi.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Demo/scripts/pi.py
r2 r391 12 12 13 13 def main(): 14 k, a, b, a1, b1 = 2 L, 4L, 1L, 12L, 4L15 while 1:14 k, a, b, a1, b1 = 2, 4, 1, 12, 4 15 while True: 16 16 # Next approximation 17 p, q, k = k*k, 2 L*k+1L, k+1L17 p, q, k = k*k, 2*k+1, k+1 18 18 a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 19 19 # Print common digits … … 21 21 while d == d1: 22 22 output(d) 23 a, a1 = 10 L*(a%b), 10L*(a1%b1)23 a, a1 = 10*(a%b), 10*(a1%b1) 24 24 d, d1 = a//b, a1//b1 25 25 26 26 def output(d): 27 27 # Use write() to avoid spaces between the digits 28 # Use str() to avoid the 'L'29 28 sys.stdout.write(str(d)) 30 29 # Flush so the output is seen immediately
Note:
See TracChangeset
for help on using the changeset viewer.