Module Module1

    Sub Main()
        Dim sum As Integer = 0, i As Integer, n As Integer
        Console.WriteLine("*** ***")
        Console.WriteLine(vbLf & ">>> VB.Net Program to print Sum of Series 1+2+3+..+n <<<")
        Console.Write(vbLf & " Enter the nth number of series: ")
        n = Convert.ToInt32(Console.ReadLine()) 'taking input, converting to Int
        For i = 1 To n
            sum += i 'calculating sum 
        Console.WriteLine(vbLf & " Sum of series upto  {0} is : {1}", n, sum)
    End Sub

End Module

Sample Output: 

Vb.Net Sum Of Series


Leave a Reply

Your email address will not be published.