Count the Primes within a Range

Published by ben3297 in

Given two integers create a function that counts the number of primes between the two given integers.

Examples

primeCount(1, 10) ➞ 4
// range = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// primes = [2, 3, 5, 7]
// answer = 4

primeCount(1, 100) ➞ 25

primeCount(1, 1000) ➞ 168

Notes

If there are no primes within the given range, return 0.

Watch a quick demo on how Edabit works.