Dsa
Math
Easy
Sum of Consecutive Primes
Given an integer N, calculate the sum of the first N consecutive prime numbers. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers.
Input Format:
- A single integer N (1 <= N <= 1000)
Output Format:
- Print a single integer, which is the sum of the first N consecutive prime numbers.
Example:
Input:
5
Output:
28
(Explanation: The first 5 prime numbers are 2, 3, 5, 7, and 11; their sum is 28).
Key concepts
mathprimessumming
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now