Function Sqrt(ByVal value As BigInteger) As BigInteger
Dim a As BigInteger = BigInteger.One
Dim b As BigInteger = (value >> 5) + 8
While (b.CompareTo(a) >= 0)
Dim m As BigInteger = BigInteger.Add(a, b) >> 1
If (BigInteger.Multiply(m, m).CompareTo(value) > 0) Then
b = BigInteger.Subtract(m, BigInteger.One)
Else
a = BigInteger.Add(m, BigInteger.One)
End If
End While
Return BigInteger.Subtract(a, BigInteger.One)
End Function
Dim bI As BigInteger = New BigInteger
BigInteger.TryParse("265657159959580629138389106654927260761", bI)
bI = Sqrt(bI)