Module Module1

    Sub Main()
        'Задача 19 с экзамена: Посчитать функцию,заданную формулой при L=1 суммировать, пока 1/2n-1<E,Е=0.001
        Dim x, sum As Double
        Const eps As Double = 0.001
        Dim L As Integer = 1
        Dim n As Integer
        Dim xmin As Double = -1
        Dim xmax As Double = 1
        Dim dx As Double = 0.1
        For i As Integer = 0 To CInt((xmax - xmin) / dx)
            x = xmin + i * dx
            sum = 0
            n = 1
            Do Until 1 / (2 * n - 1) < eps
                sum = sum + 1 / (2 * n - 1) * (Math.Sin((2 * n - 1) * Math.PI * x / L))
                n = n + 1
            Loop
            sum = sum * 4 / Math.PI
            Console.WriteLine(" {0,4:F1}   {1:f5}", x, sum)
        Next i
        Console.ReadLine()
    End Sub

End Module
