home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / sci / math / 13164 < prev    next >
Encoding:
Text File  |  1992-10-14  |  1.8 KB  |  42 lines

  1. Newsgroups: sci.math
  2. Path: sparky!uunet!mcsun!sunic!kth.se!vana!TORDM
  3. From: tordm@vana (Tord G.M. Malmgren)
  4. Subject: Re: Calculating pi: help!
  5. Message-ID: <1992Oct14.112018.19335@kth.se>
  6. Sender: usenet@kth.se (Usenet)
  7. Nntp-Posting-Host: vana.physto.se
  8. Reply-To: TordM@VanA.PhySto.SE
  9. Organization: Department of Physics, University of Stockholm -- Sweden
  10. References: <Bw304E.LKu@mentor.cc.purdue.edu>,<7557@charon.cwi.nl>
  11. Date: Wed, 14 Oct 1992 11:20:18 GMT
  12. Lines: 28
  13.  
  14. In article <7557@charon.cwi.nl>, dik@cwi.nl (Dik T. Winter) writes:
  15.  
  16. [...]
  17. >But below you will find a short C program that will give you
  18. >pi to 800 digits:
  19. >int a=10000,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;for(;d=0,g=c*2;c
  20. >-=14,printf("%.4d",e+d/a),e=d%a)for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);}
  21. >It takes less than a second on a high-end work-station.
  22.  
  23.  very cryptic and somewhat fast, but it yields a somewhat faulty results
  24. Pi:
  25. 3141592653589793238462643383279502884197169399375105820974944592307816406286208
  26. 9986280348253421170679821480865132823066470938446095505822317253594081284811174
  27. 5028410270193852110555964462294895493038196442881097566593344612847564823378678
  28. The above routine:
  29. 31415926535897932384626433832795 2884197169399375105820974944592307816406286208
  30. 9986280348253421170679821480865132823 66470938446 955 5822317253594081284811174
  31. 502841 27019385211 555964462294895493038196442881097566593344612847564823378678
  32.  where the empty spaces marks where your routine misses a digit -- format err?
  33.  
  34.  
  35.  
  36.  
  37. ---------------+--------------------------------
  38.  Tord Malmgren | InterNet: TordM@VanA.PhySto.SE | These opinions are my OWN,
  39.                | BITNet  : TordM@SESUF51        | and NOT of this department!
  40. ---------------+--------------------------------
  41.  Department of Physics, University of Stockholm
  42.