View on GitHub

marymafa.github.io


layout: post title: sum All Primes date: 2017-11-15 —

Sum all Primes

We are asked to find the sum of the prime number up to and including the provided number.

About Prime:

A prime number is defined as a number greather than one and having only two divisors, one and itself. For example, 2 is a prime number because it’s only divisible by one and two.

My Approach

Method 1

I have created the second function called primeNumbers that will check to see if number we pass in is a prime number or not. If is a prime number should return true.

Method 2

I have included an if statement that if is prime numbers , should push it to a variable called array of prime and after pushing then return the sum of primes.

Finally, both functions will execute the sum of the prime numbers and check whether the numbers are prime numbers or not.