Option Strict On
Module Module1
    Function P(ByVal n As Double, ByVal x As Double) As Double
        If n = 0 Then
            Return 1
        ElseIf n = 1 Then
            Return x
        Else
            Return ((2 * n - 1) * x * P(n - 1, x) - (n - 1) * P(n - 2, x)) / n
        End If
    End Function
    Sub Main()
        Dim x As Double
        Dim xmax As Double = 1
        Dim xmin As Double = 0
        Dim n As Double = 5
        Dim dx As Double = 0.1
        For i As Integer = 0 To CInt((xmax - xmin) / dx)
            x = xmin + dx * i
            Console.WriteLine("{0}   {1}", x, P(n, x))
        Next i
        Console.ReadLine()
    End Sub

End Module
