Statistics

Problem Statement for "Multiples"

Problem Statement

You are to create a class Multiples with a method number, which takes three ints: min, max, and factor.

Given a range of integers from min to max (inclusive), determine how many numbers within that range are evenly divisible by factor.

Definition

Class:
Multiples
Method:
number
Parameters:
int, int, int
Returns:
int
Method signature:
int number(int min, int max, int factor)
(be sure your method is public)

Notes

  • If x is evenly divisble by y, there exists some integer k such that k * y = x.

Constraints

  • min will be between -1000000 and 1000000, inclusive.
  • max will be between -1000000 and 1000000, inclusive.
  • max will be greater than or equal to min.
  • factor will be between 1 and 1000, inclusive.

Examples

  1. 0

    14

    5

    Returns: 3

    The numbers 0, 5, and 10 are evenly divisible by 5, so this returns 3.

  2. 7

    24

    3

    Returns: 6

    The numbers 9, 12, 15, 18, 21, 24 are evenly divisible by 3, so this returns 6.

  3. -123456

    654321

    997

    Returns: 780

  4. 65456

    456789

    13

    Returns: 30102

  5. 798125

    987546

    789

    Returns: 240

  6. 15231

    42342

    324

    Returns: 83

  7. 784536

    789415

    358

    Returns: 14

  8. -706454

    89124

    841

    Returns: 946

  9. -75312

    407891

    14

    Returns: 34515

  10. -1000000

    1000000

    1

    Returns: 2000001

  11. -1000000

    1000000

    1000

    Returns: 2001

  12. 45612

    761323

    2

    Returns: 357856

  13. 1000000

    1000000

    4

    Returns: 1

  14. 1000000

    1000000

    3

    Returns: 0

  15. -1000000

    -100000

    7

    Returns: 128572

  16. -1000000

    -999999

    2

    Returns: 1

  17. -4

    4

    5

    Returns: 1

  18. 2

    5

    1

    Returns: 4

  19. 0

    1000

    2

    Returns: 501

  20. 10

    10

    5

    Returns: 1

  21. -3

    -2

    5

    Returns: 0

  22. -5

    -1

    5

    Returns: 1

  23. 2

    10

    2

    Returns: 5

  24. -1

    -1

    2

    Returns: 0

  25. 4

    6

    1

    Returns: 3

  26. 4

    5

    12

    Returns: 0

  27. 7

    8

    8

    Returns: 1


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: