Option Strict On
Imports System.IO
Module Module1
    Function T(ByVal n As Double, ByVal x As Double) As Double
        If n = 0 Then
            Return 1
        ElseIf n = 1 Then
            Return 2 * x
        Else
            Return 2 * x * T(n - 1, x) - T(n - 2, x)
        End If
    End Function
    Sub Main()
        Dim x As Double
        Dim n As Double = 5
        Dim Xmax As Double = 1
        Dim Xmin As Double = -1
        Dim dx As Double = 0.1
        Dim writer As StreamWriter = New StreamWriter("out.csv")

        For i As Integer = 0 To CInt((Xmax - Xmin) / dx)
            x = Xmin + i * dx
            Console.WriteLine("{0,6:F2}    {1,10:F4}", x, T(n, x))
            writer.WriteLine("{0,6:F2} ;   {1,10:F4}", x, T(n, x))
        Next i
        writer.Close()
        Console.ReadLine()
    End Sub

End Module
