LA - It's All About Three

From Algorithmist
Jump to navigation Jump to search

Consider the series of numbers whose all prime factors have 3 as their least (right-most) digit. For example, the first 10 numbers in this series are: 3 9 13 23 27 39 43 53 69 73 The numbers 3, 13, 23, 43, 53, and 73 are in this series since they’re all primes whose least digit is a 3. Whereas 9 (3 * 3,) 27 (3 * 3 * 3,) 39 (3 * 13,) and 69 (23 * 3) are in since all their prime factors have a 3 as their least digit. Write a program that takes a list of positive integers and determines if each integer is in this series or not.

Input[edit]

The input file contains a list of one or more positive integers, each given on a separate line. Each integer is less than a million. The last line of the file contains a -1 (which is not part of the list.)

Output[edit]

For each number in the input, write, on a separate line, the number itself followed by the word "YES" if the number is in the series described above, or "NO" if it isn’t. Separate the number from the answer by a single space.

Sample Input[edit]

3
13
33
-1

Output for the Sample Input[edit]

3 YES
13 YES
33 NO

Analyses[edit]

Solutions[edit]

If you solve this problem, please provide a link to your solution here.