Problem
Given two natural numbers start and end, write a function solution that returns the count of prime numbers between start and end (inclusive).
A prime number is a natural number greater than 1 that has no divisors other than 1 and itself. For example, 2, 3, 5, 7 are prime numbers, but 4, 6, 8 are not.
Constraints
startandendare natural numbers between 1 and 100 inclusive.startis less than or equal toend.
Test Case
| Test Case Number | start | end | return |
|---|---|---|---|
| 1 | 1 | 10 | 4 |
| 2 | 10 | 20 | 4 |
| 3 | 5 | 5 | 1 |
Explanation for Test Case 1
- When
start = 1andend = 10, the prime numbers between 1 and 10 are2, 3, 5, 7, so the count is 4.
Explanation for Test Case 2
- When
start = 10andend = 20, the prime numbers between 10 and 20 are11, 13, 17, 19, so the count is 4.
Explanation for Test Case 3
- When
start = 5andend = 5, 5 is a prime number, so the count is 1.