Statistics

Problem Statement for "DigitPrime"

Problem Statement

A number is called 2-digit-prime if using each of its digits at most once, we can make a prime number containing exactly 2 digits (with no leading zeros). For example, 153 is 2-digit-prime because we can use its digits to make 13, which is a prime number with 2 digits (note that we can also make 53 and 31). Given ints a and b, return the number of 2-digit-prime numbers between a and b, inclusive. See examples for further clarification.

Definition

Class:
DigitPrime
Method:
countNumbers
Parameters:
int, int
Returns:
int
Method signature:
int countNumbers(int a, int b)
(be sure your method is public)

Constraints

  • b will be between 10 and 100000, inclusive.
  • a will be between 10 and b, inclusive.

Examples

  1. 11

    20

    Returns: 6

    2-digit-prime numbers are: 11 (note that we can use some digit twice if it appears twice in the number), 13, 14 (using its digits we can make 41), 16 (we can make 61), 17 and 19.

  2. 37

    98

    Returns: 21

  3. 9003

    9003

    Returns: 0

    Note that we are looking for 2 digit prime numbers with no leading zeros, so 03 is not considered a 2 digit prime number.

  4. 11

    11111

    Returns: 8777

  5. 97463

    100000

    Returns: 2436

  6. 33561

    33601

    Returns: 40

    The only number in this interval that is not 2-digit-prime is 33600.

  7. 11000

    11999

    Returns: 1000

    Each number in this interval is 2-digit-prime.

  8. 10

    100000

    Returns: 87281

  9. 872

    2390

    Returns: 1298

  10. 13

    4003

    Returns: 3149

  11. 55

    55555

    Returns: 48244

  12. 11

    99999

    Returns: 87281

  13. 12321

    98789

    Returns: 76218

  14. 100000

    100000

    Returns: 0

  15. 10

    10

    Returns: 0

  16. 542

    9841

    Returns: 7268

  17. 7392

    74519

    Returns: 58906

  18. 26

    998

    Returns: 594

  19. 1010

    10101

    Returns: 7208

  20. 9739

    10929

    Returns: 1104

  21. 25775

    34342

    Returns: 7713

  22. 29642

    58211

    Returns: 25169

  23. 15658

    17133

    Returns: 1460

  24. 31465

    49493

    Returns: 16401

  25. 23390

    26813

    Returns: 2697

  26. 25814

    32290

    Returns: 5704

  27. 14636

    37053

    Returns: 20177

  28. 8361

    24189

    Returns: 14519

  29. 3279

    18948

    Returns: 13947

  30. 24921

    52871

    Returns: 24531

  31. 25824

    31777

    Returns: 5186

  32. 2693

    31764

    Returns: 25270

  33. 6537

    34145

    Returns: 24620

  34. 12616

    19503

    Returns: 6744

  35. 8920

    18426

    Returns: 9182

  36. 25837

    42016

    Returns: 14966

  37. 8613

    35633

    Returns: 24507

  38. 15027

    25574

    Returns: 9297

  39. 25066

    53012

    Returns: 24553

  40. 9431

    27112

    Returns: 15872

  41. 25876

    39963

    Returns: 13162

  42. 26375

    47243

    Returns: 18828

  43. 7730

    32630

    Returns: 22194

  44. 29647

    55234

    Returns: 22842

  45. 10962

    20403

    Returns: 9126

  46. 11111

    16789

    Returns: 5551

  47. 80000

    80999

    Returns: 675

  48. 11111

    11111

    Returns: 1

  49. 32

    32

    Returns: 1

  50. 142

    555

    Returns: 263

  51. 30

    30

    Returns: 0

  52. 1111

    1111

    Returns: 1

  53. 113

    113

    Returns: 1

  54. 10

    10000

    Returns: 7729

  55. 31

    31

    Returns: 1

  56. 1320

    1320

    Returns: 1

  57. 43

    43

    Returns: 1

  58. 821

    821

    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: