Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/Pi/PureBasic/pi.basic
Normal file
40
Task/Pi/PureBasic/pi.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#SCALE = 10000
|
||||
#ARRINT= 2000
|
||||
|
||||
Procedure Pi(Digits)
|
||||
Protected First=#True, Text$
|
||||
Protected Carry, i, j, sum
|
||||
Dim Arr(Digits)
|
||||
For i=0 To Digits
|
||||
Arr(i)=#ARRINT
|
||||
Next
|
||||
i=Digits
|
||||
While i>0
|
||||
sum=0
|
||||
j=i
|
||||
While j>0
|
||||
sum*j+#SCALE*arr(j)
|
||||
Arr(j)=sum%(j*2-1)
|
||||
sum/(j*2-1)
|
||||
j-1
|
||||
Wend
|
||||
Text$ = RSet(Str(Carry+sum/#SCALE),4,"0")
|
||||
If First
|
||||
Text$ = ReplaceString(Text$,"3","3.")
|
||||
First = #False
|
||||
EndIf
|
||||
Print(Text$)
|
||||
Carry=sum%#SCALE
|
||||
i-14
|
||||
Wend
|
||||
EndProcedure
|
||||
|
||||
If OpenConsole()
|
||||
SetConsoleCtrlHandler_(?Ctrl,#True)
|
||||
Pi(24*1024*1024)
|
||||
EndIf
|
||||
End
|
||||
|
||||
Ctrl:
|
||||
PrintN(#CRLF$+"Ctrl-C was pressed")
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue