SUMMATION & PRIME NUMBER TOOL

Sum of Prime Numbers Calculator

Calculate the sum of all prime numbers between two integers. This calculator uses the Sieve of Eratosthenes to identify primes and provides a step-by-step explanation of the calculation.

Calculate the Sum of Primes

What Is a Prime Number?

A prime number is a whole number greater than 1 that has exactly two positive divisors: 1 and itself.

For example, 2, 3, 5, 7, 11, 13, 17 and 19 are prime numbers. The number 12 is not prime because it can be divided by 1, 2, 3, 4, 6 and 12.

\[ p > 1,\qquad p \text{ is prime if its only positive divisors are } 1 \text{ and } p \]

The number 2 is the only even prime number. Every other even number greater than 2 is divisible by 2 and therefore is not prime.

What Is the Sum of Prime Numbers?

The sum of primes in an interval is obtained by adding every prime number that falls within the specified range.

If the primes between \(a\) and \(b\) are \(p_1,p_2,\ldots,p_m\), then their sum is

\[ \sum_{\substack{p\text{ prime}\\a\le p\le b}} p = p_1+p_2+\cdots+p_m \]

For example, the prime numbers from 10 through 20 are \(11,13,17,19\). Therefore,

\[ 11+13+17+19=60 \]

How the Sieve of Eratosthenes Works

The Sieve of Eratosthenes is a classic algorithm for finding all prime numbers up to a specified limit.

  1. Create a list of integers from 2 through \(N\).
  2. Start with the smallest unmarked number, 2.
  3. Mark all multiples of 2 greater than 2 as composite.
  4. Move to the next unmarked number.
  5. Mark its multiples as composite.
  6. Continue until the current number is greater than \(\sqrt{N}\).
  7. Every number remaining unmarked is prime.
\[ p \le \sqrt{N} \]

Only prime candidates up to \(\sqrt{N}\) need to be processed when generating the sieve.

Example: Sum of Primes from 1 to 30

The prime numbers between 1 and 30 are:

\[ 2,3,5,7,11,13,17,19,23,29 \]

Adding them gives:

\[ 2+3+5+7+11+13+17+19+23+29=129 \]

Therefore, the sum of all primes from 1 through 30 is 129.

Prime Counting Function

The number of primes less than or equal to \(x\) is represented by the prime-counting function \(\pi(x)\).

\[ \pi(x)=\#\{p\le x:p\text{ is prime}\} \]

This calculator effectively identifies the primes in the selected interval and can therefore also determine how many primes occur between the two endpoints.

The number of primes from \(a\) through \(b\) can be expressed as

\[ \pi(b)-\pi(a-1) \]

Important Facts About Prime Numbers

  • 1 is not a prime number.
  • 2 is the only even prime number.
  • Every integer greater than 1 is either prime or can be factored into primes.
  • There are infinitely many prime numbers.
  • Every composite number greater than 1 has at least one prime factor.
  • A number greater than 1 is composite if it has a divisor other than 1 and itself.

How to Use the Sum of Primes Calculator

  1. Enter the lower number in the Start Number field.
  2. Enter the upper number in the End Number field.
  3. Make sure the start number is not greater than the end number.
  4. Click Calculate Sum of Primes.
  5. The calculator identifies the primes using the Sieve of Eratosthenes.
  6. The prime numbers and their total are displayed when the result is available.

The calculator accepts non-negative integers and is designed for practical educational calculations.

Related Math Calculators

Explore other Summe tools for summation, sequences, number theory and related calculations:

Σ Sigma Calculator

Evaluate summation notation and finite sums.

Sum of a Series Calculator

Calculate sums of finite mathematical series.

Prime Sum in a Range

Calculate prime sums over a selected interval.

Prime Factorization Calculator

Find the prime factors of an integer.

Sum of Squares Calculator

Calculate sums of consecutive squared integers.

Sum of Cubes Calculator

Calculate sums of consecutive cubes.

Fibonacci Sum Calculator

Calculate sums involving Fibonacci sequences.

Sum of Divisors Calculator

Calculate the sum of positive divisors of a number.

Frequently Asked Questions

What is the sum of prime numbers?

It is the total obtained by adding every prime number within a specified range. For example, the primes from 1 to 10 are 2, 3, 5 and 7, whose sum is 17.

Is 1 a prime number?

No. A prime number must have exactly two positive divisors: 1 and itself. The number 1 has only one positive divisor.

What is the smallest prime number?

The smallest prime number is 2. It is also the only even prime number.

What algorithm does this calculator use?

The calculator uses the Sieve of Eratosthenes to generate prime numbers up to the selected upper limit. It then selects the primes inside the requested range and adds them together.

Why does the sieve start marking multiples at \(p^2\)?

Any smaller multiple of \(p\) has already been marked by a smaller prime factor. Therefore, when processing a prime \(p\), its first new multiple that needs to be marked is \(p^2\).

Can the calculator sum primes starting from a number other than 1?

Yes. Enter any non-negative start value together with a larger or equal end value. Only prime numbers within the selected interval are included.

What is the sum of the first few prime numbers?

The first primes are 2, 3, 5, 7, 11, 13, 17 and 19. Their sum is 77.

Does the calculator include composite numbers?

No. Composite numbers and the number 1 are excluded. Only numbers identified as prime by the sieve are included in the final sum.