Compute pi to base 12 using Python?

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Sun Apr 17 04:45:41 EDT 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

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.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven



More information about the Python-list mailing list