Sum of Prime Numbers Calculator

Enter a starting number and an ending number to calculate all prime numbers and their sum within the range.

Calculate the Sum of All Prime Numbers

Sum

Prime Numbers

What Are Prime Numbers?

A prime number is a positive integer greater than 1 that has exactly two distinct positive divisors: 1 and itself. Examples of prime numbers include 2, 3, 5, 7, 11, and so on. Prime numbers are fundamental in number theory because they are the basic building blocks of all integers, with every positive integer uniquely represented as a product of primes.

Characteristics of Prime Numbers:

  • 2 is the only even prime number; all other primes are odd.
  • A prime number has only two divisors: 1 and itself. This distinguishes primes from composite numbers.
  • Numbers greater than 1 that are not prime are called composite numbers. A composite number has at least one divisor other than 1 and itself.

How to Calculate the Sum of All Prime Numbers in a Range?

  1. Check each number for primality: Starting from the first number in the range, check each number to determine if it is prime. How to check: For each number \( n \), check if it has any divisors other than 1 and itself. To optimize the check, only test divisors up to \( \sqrt{n} \).
  2. Add the primes together: Once all the prime numbers in the range are identified, add them up to get the sum.

Examples

Example 1: Calculate the sum of all prime numbers between 10 and 20

Solution:

1. Find all the prime numbers between 10 and 20:

11, 13, 17, 19.

2. Add these primes together:

\( 11 + 13 + 17 + 19 = 60 \)

Result: The sum of primes between 10 and 20 is 60.

Example 2: Calculate the sum of all prime numbers between 1 and 100

Solution:

1. Find all the prime numbers between 1 and 100:

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.

2. Add these primes together:

\( 2 + 3 + 5 + 7 + ... + 89 + 97 = 1060 \)

Result: The sum of primes between 1 and 100 is 1060.