CCC '05 J2 - RSA Numbers

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2005 Stage 1, Junior #2

When a credit card number is sent through the Internet it must be protected so that other people cannot see it. Many web browsers use a protection based on "RSA Numbers."

A number is an RSA number if it has exactly four divisors. In other words, there are exactly four numbers that divide into it evenly. For example, 10 is an RSA number because it has exactly four divisors (1, 2, 5, 10). 12 is not an RSA number because it has too many divisors (1, 2, 3, 4, 6, 12). 11 is not an RSA number either. There is only one RSA number in the range 10 \dots 12.

Write a program that inputs a range of numbers and then counts how many numbers from that range are RSA numbers. You may assume that the numbers in the range are less than 1000.

Sample Input 1

10
12

Sample Output 1

The number of RSA numbers between 10 and 12 is 1

Sample Input 2

11
15

Sample Output 2

The number of RSA numbers between 11 and 15 is 2

Comments


  • 0
    ibex  commented on Dec. 14, 2024, 5:40 a.m.

    To whoever sees this, good luck on your coding journey!!! :)


  • -4
    BaconBest  commented on April 29, 2021, 8:12 p.m.

    when i try 11 and 15, it prints one. whyy


    • 0
      TheCallousSword  commented on July 14, 2021, 11:42 p.m.

      15 is an rsa number (1,3,5,15)


  • 12
    jaihysc  commented on Dec. 9, 2019, 11:38 p.m.

    It should be noted that the range inputted is inclusive.


    • 4
      Super_User  commented on Dec. 29, 2019, 3:37 a.m. edited

      For example, 10 is an RSA number because it has exactly four divisors (1, 2, 5, 10). 12 is not an RSA number because it has too many divisors (1, 2, 3, 4, 6, 12). 11 is not an RSA number either. There is only one RSA number in the range 10 \dots 12.

      It explains in the description. The range is 10-12 and the numbers tested were 10, 11 & 12.