If you have ever tried solving any mathematical question or coding challenge or even an aptitude test, you must have come across the sum of first N even numbers. Rather than calculating the sum through individual additions, you can calculate the sum using a simple formula.
The above idea will be useful not just in mathematics but also in the areas of Data Structure and Algorithms (DSA), competitive programming, and coding interviews where pattern recognition is used to solve coding problems.
If you are preparing for the interviews of product-based companies, then apart from preparing DSA, developing your mathematical fundamentals would really help you solve problems better.
What Is the Sum of First N Even Numbers?
Even numbers are those whole numbers which are completely divisible by 2.
The series of even numbers goes like:
2, 4, 6, 8, 10, 12, 14, ...
Sum of first N even numbers refers to the total of first N positive even numbers.
Examples
First 3 even numbers = 2 + 4 + 6 = 12
First 5 even numbers = 2 + 4 + 6 + 8 + 10 = 30
First 8 even numbers = 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 = 72
There is no need to perform addition again and again; you can simply apply a trick to find the answer within a few seconds.
Quick Tip: In case there appears a phrase 'first N even numbers,' instantly recall the following formula:
Sum = N × (N + 1)
Formula to Find the Sum of First N Even Numbers
The formula is:
Sum = N × (N + 1)
Where:
- N = Number of even numbers
- Sum = Total of first N even numbers
Example
Calculate the sum of first 12 even numbers.
From the above formula:
Sum = 12 × (12 + 1)
= 12 × 13
= 156
Answer: 156
Why Does This Formula Work?
Let us derive the formula in a step by step manner.
First N even numbers:
2, 4, 6, 8, …, 2N
Sum = 2 + 4 + 6 + … + 2N
Taking 2 as common:
2 x (1 + 2 + 3 + … + N)
From the well-known formula of first N natural numbers:
1 + 2 + 3 + … + N = N(N + 1)/2
Putting the above formula in our sum equation:
2 x N(N + 1)/2
Here the 2 will cancel out:
N(N + 1)
Thus,
Sum of first N even numbers = N × (N + 1)
Understand the Pattern
Here is what you notice when you keep on adding even numbers together:
| Number of Even Numbers | Numbers Sum | Formula |
|---|---|---|
| 2 | 2 | 1 × 2 |
| 2+4 | 6 | 2 × 3 |
| 2 + 4 + 6 | 12 | 3 × 4 |
| 2 + 4 + 6 + 8 | 20 | 4 × 5 |
| 2 + 4 + 6 + 8 + 10 | 30 | 5 × 6 |
A clear pattern appears:
Sum = N × (N + 1)
It is very important to spot patterns like this because they make solving mathematics and programming questions much easier.
Solved Examples
Example 1
Find the sum of the first 6 even numbers.
Solution
Sum = 6 × (6 + 1)
= 6 × 7
= 42
Answer: 42
Example 2
Find the sum of the first 50 even numbers.
Solution
Sum = 50 × (50+1)
= 2550
Answer: 2550

Why Use the Formula Instead of Addition?
Let us consider adding up to the first 1,000 even numbers.
It will take time to perform calculations sequentially and give room for making mistakes.
With the formula:
1000 × 1001 = 1,001,000
You will receive an instant result.
This is precisely why the interviewers and developers appreciate the mathematical approach more than doing repetitive tasks.
Interview Tip: During coding interviews, most candidates use the loop method for solving this task (O(N)). The better method to solve the same is via the mathematical formula (O(1)).
Try It Yourself
Without looking at the answers, try solving the following problems using the formula:
- Sum of first 7 even numbers
- Sum of first 15 even numbers
- Sum of first 25 even numbers
Answers:
- 56
- 240
- 650
If you have correctly solved all three of them, then you have already mastered the formula.
C Program to Find the Sum of First N Even Numbers
#include <stdio.h>
int main() {
int n;
printf("Enter N: ");
scanf("%d", &n);
int sum = n * (n + 1);
printf("Sum = %d", sum);
return 0;
}Output
Enter N: 8
Sum = 72Time Complexity: O(1)
Space Complexity: O(1)
C++ Program for Sum of First N Even Numbers
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter N: ";
cin >> n;
int sum = n * (n + 1);
cout << "Sum = " << sum << endl;
return 0;
}Output
Enter N: 8
Sum = 72Time Complexity: O(1)
Space Complexity: O(1)

Java Program for Sum of First N Even Numbers
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter N: ");
int n = sc.nextInt();
int sum = n * (n + 1);
System.out.println("Sum = " + sum);
sc.close();
}
}Output
Enter N: 8
Sum = 72Time Complexity: O(1)
Space Complexity: O(1)
Real-World Applications of the Sum of First N Even Numbers
Though this equation seems very easy, it has its applications in math and computing. Understanding number patterns enables you to solve problems in an efficient way and improves your analytical skills.
Some of the real-world applications are as follows:
- Solving aptitude and quantitative reasoning problems
- Programming and developing algorithms using number patterns
- Competitive programming
- Understanding math patterns in DSA
- Developing logic for coding interview preparation
If you're preparing for software engineering roles, mastering these small concepts can make solving larger algorithmic problems much easier. This is the reason that the learners of Bosscoder Academy are taught mathematical reasoning along with DSA, System Design, and Problem Solving.
Common Mistakes to Avoid
1. Using an Incorrect Formula
Do not confuse the formula for even numbers with that for odd numbers.
For the first N even numbers:
Sum = N × (N+1)
2. Starting The Sequence With 0
Unless the question specifically includes 0, the first positive even number is 2.
Correct sequence:
2, 4, 6, 8, ...
3. Considering N As The Last Even Number
Note that:
N is the number of terms.
Last Term = 2N
For Example:
If N=8, the last even number will be 16 and not 8.
4. Using a Loop Unnecessarily
Most beginners prefer looping to find the sum of all even numbers.
Though possible, looping slows down the process. Use the mathematical formula to solve this problem.
Tip For Optimization: When you have a choice to replace repetitive operations with a mathematical formula, use it.
Quick Recap
Please note down these important things:
| Concept | Formula |
|---|---|
| First even number | 2 |
| Nth even number | 2N |
| Sum of first N even numbers | N × (N + 1) |
| Time Complexity (Formula) | O(1) |
| Space Complexity | O(1) |
Important Points to Remember
Here's a quick recap before moving further:
- Even numbers are always divisible by 2.
- First few even numbers are 2, 4, 6, 8, 10 ...
- Formula to calculate sum of first N even numbers is N × (N + 1).
- Formula to calculate sum of first N even numbers is based on sum of first N natural numbers.
- It's much faster to use formula than to add numbers.
- Optimized code will take O(1) time to execute.
- This concept is used in various mathematical problems, aptitude tests, competitive programming, etc.
Conclusion
Sum of first N even numbers is one of the simplest yet most valuable mathematical equations. Rather than adding all even numbers one by one, we can simply find out the solution using:
Sum = N × (N + 1)
Not only does this help us in mathematics but this equation also gives us an insight into programming that is look for a pattern before creating a loop. Using mathematically optimized ways will definitely result in better and effective code which interviewers like in product-based companies.
While learning DSA and programming further, make sure you practice this type of basic concepts. Such minor optimizations prove helpful in solving future algorithmic problems. Platforms like Bosscoder Academy focus on these fundamentals so learners can strengthen their problem-solving skills and perform confidently in technical interviews.
Frequently Asked Questions (FAQs)
Q1. What is the formula for the sum of first N even numbers?
The formula is:
Sum = N × (N + 1)
Here, N is the number of even numbers.
Q2. What is the nth even number?
The nth even number will be:
2N
For example:
5th even number = 10
12th even number = 24
20th even number = 40
Q3. Is 0 an even number?
Yes. Mathematically, 0 is an even number because it is divisible by 2 without leaving a remainder.
Q4. Why is the formula useful in programming?
We do not need to write a loop which takes O(N) time, but directly get the answer in O(1) time.









