This website completely moved to new platform. For latest content, visit

Search this Site

18 Aug 2013

VB.Net Program to Print Sum Of Series 1+2+3+..+n

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: