Problem Statement
The Prime Number Theorem describes the density of prime numbers. Your program is going to help test this theorem.
A number is prime if it is greater than 1, and is only evenly divisible by itself and 1. Given ints lower and upper you will return how many primes there are between lower and upper inclusive.
A number is prime if it is greater than 1, and is only evenly divisible by itself and 1. Given ints lower and upper you will return how many primes there are between lower and upper inclusive.
Definition
- Class:
- PrimeNumThm
- Method:
- howMany
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int howMany(int lower, int upper)
- (be sure your method is public)
Constraints
- lower will be between 2 and 5000000 inclusive.
- upper will be between 2 and 5000000 inclusive.
- lower will be at most upper.
Examples
2
5
Returns: 3
2, 3, and 5 are prime7
7
Returns: 1
7 is prime14
16
Returns: 0
No primes here2
1000
Returns: 168
2
5000000
Returns: 348513