Statistics

Problem Statement for "PrimesBetween"

Problem Statement

A prime number is one that has exactly two divisors: 1 and itself. The first few primes are 2, 3, 5, 7, 11.

Given start and end, how many prime numbers are there between those bounds, inclusive?

Definition

Class:
PrimesBetween
Method:
count
Parameters:
int, int
Returns:
int
Method signature:
int count(int start, int end)
(be sure your method is public)

Constraints

  • start will be between 1 and 100, inclusive.
  • end will be between start and 100, inclusive.

Examples

  1. 2

    11

    Returns: 5

    These are the primes listed in the problem statement.

  2. 8

    10

    Returns: 0

    Note that none of 8, 9, or 10, are prime, so we return 0.

  3. 12

    20

    Returns: 3

    The primes here are 13, 17, 19.

  4. 1

    100

    Returns: 25

  5. 20

    30

    Returns: 2

    23 and 29.

  6. 1

    1

    Returns: 0


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: