IsaacAsimov Posted May 25, 2012 Posted May 25, 2012 Here's a program I wrote in Structured Basic on my C64 computer: 100 REM COMPUTING PI USING RECTANGLES 110 REM DOTS REPRESENT INDENTATIONS 120 CALL INIT 140 CALL MAIN 160 CALL OUTPUT 180 END 200 : 220 PROC INIT 240 .....TI$="000000" 260 .....A=0:B=1 280 .....N=10 300 ENDPROC 320 : 340 PROC MAIN 360 .....DX=(B-A)/N 380 .....PRINT:PRINT"DX =";DX 400 .....X=-DX 420 .....I=-1 440 .....PRINT:PRINT" I ";" X ";" Y ";" T ":PRINT 460 .....LOOP 480 ........I=I+1 500 ........X=X+DX 520 ........Y=SQR(1-X*X) 540 ........T=T+Y 560 ........PRINT I;X;Y;T 580 .....UNTIL I=N-1 600 .....PI=DX*T*4 620 ENDPROC 640 : 660 PROC OUTPUT 680 .....PRINT:PRINT"PI =";PI 700 .....PRINT:PRINT"TIME TAKEN = ";TI$ 720 ENDPROC
hypervalent_iodine Posted May 25, 2012 Posted May 25, 2012 ! Moderator Note Isaac, you already have a number of threads on calculating pi. From now on, could you please consolidate them to one thread instead of opening up others?For reference:http://www.sciencefo...__1#entry679038http://www.sciencefo...__fromsearch__1http://www.sciencefo...__fromsearch__1http://www.sciencefo...__fromsearch__1http://www.sciencefo...__fromsearch__1http://www.sciencefo...__fromsearch__1http://www.sciencefo...__fromsearch__1There are far too many of these. I am merge the non-repeating threads into the last of these links so you can use the single thread for your ideas, etc., on calculating pi. Thread closed.
Recommended Posts