Option Strict On
Module Module1
    Function factorial(ByVal n As Double) As Double
        If n = 0 Then
            Return 1
        Else
            Return n * factorial(n - 1)
        End If
    End Function
    Sub Main()
        Const eps As Double = 0.001
        Dim x As Double
        Dim xmin As Double = -1
        Dim xmax As Double = 1
        Dim dx As Double = 0.1
        Dim erf As Double = 0
        Dim n As Double = 1
        For i As Integer = 0 To CInt((xmax - xmin) / dx)
            x = xmin + i * dx
            erf = 0
            n = 1
            Do Until 1 / (2 * n + 1) < eps
                n = n + 1
                erf = erf + ((-1) ^ n) * (x ^ (2 * n + 1)) / factorial(n) / (2 * n + 1)
            Loop
            Console.WriteLine("{0}  {1}", x, erf)
        Next i
        Console.ReadLine()

    End Sub

End Module
