September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
24
Task/Pi/Visual-Basic-.NET/pi-1.visual
Normal file
24
Task/Pi/Visual-Basic-.NET/pi-1.visual
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
Imports System
|
||||
Imports System.Numerics
|
||||
|
||||
Public Module Module1
|
||||
Public Sub Main()
|
||||
Dim two, three, four, seven, ten, k, q, t, l, n, r, nn, nr As BigInteger,
|
||||
first As Boolean = True
|
||||
two = New BigInteger(2) : three = New BigInteger(3) : four = two + two
|
||||
seven = three + four : ten = three + seven : k = BigInteger.One
|
||||
q = k : t = k : l = three : n = three : r = BigInteger.Zero
|
||||
While True
|
||||
If four * q + r - t < n * t Then
|
||||
Console.Write(n) : If first Then Console.Write(".") : first = False
|
||||
nr = ten * (r - n * t) : n = ten * (three * q + r) / t - ten * n
|
||||
q *= ten
|
||||
Else
|
||||
nr = (two * q + r) * l : nn = (q * seven * k + two + r * l) / (t * l)
|
||||
q *= k : t *= l : l += two : k += BigInteger.One : n = nn
|
||||
End If
|
||||
r = nr
|
||||
End While
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
35
Task/Pi/Visual-Basic-.NET/pi-2.visual
Normal file
35
Task/Pi/Visual-Basic-.NET/pi-2.visual
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
Imports System, System.Numerics, System.Text
|
||||
|
||||
Module Program
|
||||
|
||||
Sub RunPiF(ByVal msg As String)
|
||||
If msg.Length > 0 Then Console.WriteLine(msg)
|
||||
Dim first As Boolean = True, stp As BigInteger = 360,
|
||||
lim As BigInteger = stp, res As StringBuilder = New StringBuilder(),
|
||||
rc As Integer = -1, u, j, k As BigInteger, q As BigInteger = 1,
|
||||
r As BigInteger = 180, t As BigInteger = 60, i As BigInteger = 2,
|
||||
y As Byte, et As TimeSpan, st As DateTime = DateTime.Now
|
||||
|
||||
While True
|
||||
While i < lim
|
||||
j = i << 1 : k = j + i : u = 3 * (k + 1) * (k + 2)
|
||||
y = CByte(((q * (9 * k - 12) + 5 * r) / (5 * t)))
|
||||
res.Append(y)
|
||||
r = (q * (k + j - 2) + r - y * t) * u * 10
|
||||
t *= u : q = 10 * q * (j - 1) * i : i += 1
|
||||
End While
|
||||
If first Then res.Insert(1, "."c) : first = False
|
||||
Console.Write(res.ToString())
|
||||
rc += res.Length : res.Clear() : lim += stp
|
||||
If Console.KeyAvailable Then Exit While
|
||||
End While
|
||||
et = DateTime.Now - st : Console.ReadKey()
|
||||
Console.Write(res.ToString()) : rc += res.Length
|
||||
Console.WriteLine(vbLf & "Produced {0} digits in {1:n4} seconds.", rc, et.TotalSeconds)
|
||||
End Sub
|
||||
|
||||
Sub Main(args As String())
|
||||
RunPiF("Press a key to exit...")
|
||||
If Diagnostics.Debugger.IsAttached Then Console.ReadKey()
|
||||
End Sub
|
||||
End Module
|
||||
Loading…
Add table
Add a link
Reference in a new issue