Sum of the First 50 Natural Numbers in Excel (5 Ways)

1 + 2 + 3 + … + 50 = 1,275. It's a classic puzzle, and a neat way to compare Excel tools: a one-line maths formula, SEQUENCE, SUMPRODUCT and ROW, Power Query and VBA all get there.

Answer1,275
Shortest=50*51/2
Excel 365=SUM(SEQUENCE(50))

1. The maths formula

=50*(50+1)/2

The sum of 1 to n is n(n+1)/2. Pair the numbers from both ends: 1+50, 2+49, 3+48… Each pair adds to 51, and there are 25 pairs, so 25 × 51 = 1,275. With n in A1: =A1*(A1+1)/2.

2. SUM and SEQUENCE (Excel 365)

=SUM(SEQUENCE(50))

SEQUENCE lists 1 to 50 and SUM adds them. Change 50 to any number. Sum of the even numbers: =SUM(SEQUENCE(25,,2,2)).

SUM and SEQUENCE adding 1 to 50

3. SUMPRODUCT and ROW (any version)

=SUMPRODUCT(ROW(1:50))

ROW(1:50) gives the row numbers 1 to 50, and SUMPRODUCT adds them without Ctrl + Shift + Enter. Inserting rows above it doesn't change the reference's numbers, but deleting rows 1–50 would break it.

SUMPRODUCT and ROW adding 1 to 50

4. Power Query

In a blank query (Data → Get Data → From Other Sources → Blank Query), type in the formula bar:

= List.Sum({1..50})

{1..50} is a list of the numbers 1 to 50; List.Numbers(1,50) builds the same list.

Power Query List.Sum returning 1275

5. VBA

Sub SumFirst50()
    Dim i As Long, total As Long
    For i = 1 To 50
        total = total + i
    Next i
    MsgBox total
End Sub

Related

Last updated · Written by Ajay Anand, Microsoft Excel MVP