Dim N As Int = 1000 ' The greater the value, the greater the precision
Dim PiGreek As Double = 1
For i=1 To N
PiGreek=PiGreek+Power(-1,i)/(2*i+1)
Next
Log(4*PiGreek)
2) Formulas di Machin
B4X:
Dim PiGreek As Double = 4*ATan(1/5)-ATan(1/239)
Log(4*PiGreek)
3) Formulas di Wallis
B4X:
Dim N As Int = 1000
Dim PiGreek As Double = 1
For i=1 To N
PiGreek=PiGreek*((i*2)/((i-1)*2+1))*((i*2)/((i-1)*2+3))
Next
Log(2*PiGreek)
Sub AppStart (Args() As String)
Dim CountIn As Int
Dim Total As Int = 100000000
For i = 0 To Total - 1
Dim r1 As Int = Rnd(0, 0x7fffffff)
Dim r2 As Int = Rnd(0, 0x7fffffff)
Dim x As Double = r1 / 0x7fffffff
Dim y As Double = r2 / 0x7fffffff
Dim distance2 As Double = Power(x - 0.5, 2) + Power(y - 0.5, 2)
If distance2 <= 0.25 Then CountIn = CountIn + 1
Next
Log(CountIn / Total / 0.25)
End Sub