Option Strict On
Module Module1
    Function f(ByVal n As Double, ByVal x As Double) As Double
        Return (1 / (2 * Math.PI * n)) ^ 2 * Math.Cos(2 * Math.PI * n - 1) * Math.Cos(1 / (2 * Math.PI * n * x))
    End Function
    Sub Main()
        Dim x As Double
        Dim n As Double
        Const eps As Double = 0.00001
        Dim xmin As Double = 1
        Dim xmax As Double = 2
        Dim dx As Double = 0.1
        Dim sum As Double
        For i As Integer = 0 To CInt((xmax - xmin) / dx)
            x = xmin + i * dx
            n = 1
            sum = 1
            Do Until (1 / (2 * Math.PI * n)) ^ 2 < eps
                sum = sum + f(n, x)
                n = n + 1
            Loop
            Console.WriteLine("{0,4:F4}  {1,8:F5}", x, sum)
        Next i
        Console.ReadLine()
    End Sub
End Module


