Option Strict On
Imports System.IO
Module Module1
    Function F(ByVal k As Integer) As Integer
        If k = 0 Then
            Return 1
        Else
            Return k * F(k - 1)
        End If
    End Function
    Sub Main()
        Dim out As StreamWriter = New StreamWriter("output.csv")
        Dim xmin, xmax, dx, x, sum As Double
        xmin = -1
        xmax = 1
        dx = 0.1
        Dim k As Integer
        Dim eps As Double = 0.00001
        For i As Integer = 0 To CInt((xmax - xmin) / dx)
            x = xmin + i * dx
            sum = 0
            k = 1
            Do
                sum = sum + ((-1) ^ k) / F(k) / (2 * k + 1) * (x ^ (2 * k - 1))
                k = k + 1
            Loop Until (1 / F(k) / (2 * k + 1)) < eps
            Console.WriteLine("{0,6} {1} ", x, (1 + sum))
            out.WriteLine("{0,6} {1} ", x, (1 + sum))
        Next i
        out.Close()
        Console.ReadLine()
    End Sub
End Module
