Professional Documents
Culture Documents
Erlang Kalkulator
Erlang Kalkulator
n < 0 Then Throw New Exception("Value must not be negative") End If Return fact End Function Private Function CalculatePb(ByVal A As Double, ByVal N As Integer) As Doubl e Pb As Double numerator As Double = A ^ N / Factorial(N) denominator As Double = 0.0 x As Integer = 0 To N Step 1 denominator += A ^ x / Factorial(x) Next x If denominator > 0 Then Pb = numerator / denominator End If Return Pb End Function Dim Pb As Double = CalculatePb(3, 6) 'Show the result with 4 decimal places MsgBox(Pb.ToString("F4")) Dim Dim Dim For