Compute pi to base 12 using Python?

Dick Moores rdm at rcblue.com
Sun Apr 17 05:23:54 EDT 2005


Roel Schroeven wrote at 01:45 4/17/2005:
>Dick Moores wrote:
>>M.E.Farmer wrote at 23:18 4/14/2005:
>>
>>> > >Using the GNU "bc" utility:
>>> > >
>>> > >   $ bc -l
>>> > >   bc 1.06
>>> > >   Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation,
>>>Inc.
>>> > >   This is free software with ABSOLUTELY NO WARRANTY.
>>> > >   For details type `warranty'.
>>> > >   scale = 3000    # number of output places wanted
>>> > >   obase = 12      # output base
>>> > >   print 4 * a(1)  # pi = 4*arctan(1)
>>
>>Wow! this got me the 3003 (changed from 3000) digits of pi to base 12 
>>in 60.8 secs. No, I didn't count them yet, nor am I sure they're 
>>correct. But I'd bet on them..
>>Could someone remind me how to get the output of bc -l into a text file 
>>on Windows? (I've tried employing " > pi3003.txt" in various ways) OR, 
>>how to copy and paste from the command line window, or whatever that 
>>window is called? (Sorry for the OT question.)
>
>Works for me (using the Cygwin version though) when I do
>
>C:\cygwin\bin\bc -l > pi12.txt

But how or when do you enter the lines

scale = 3000
obase = 12
print 4 * a(1)

>Otherwise, to copy from the command prompt window: open the system menu
>(icon in the top left corner of the window) and choose Edit->Mark. Then
>select what you want to copy and press Enter or choose Edit->Copy in the
>system menu.

Thanks! You've just relieved years of frustration.

Dick 




More information about the Python-list mailing list