Hide

Problem A
Integer Properties

Languages en is

Write a program that does the following:

  1. First, repeatedly checks whether an integer has $10$ positive divisors or more. A number $d$ is said to be a divisor of $n$ if there is no remainder after dividing $n$ by $d$. The repetition should stop as soon as q or Q is entered.

  2. Second, reads the integer $n$ from the keyboard. Finds and prints:

    1. all positive two digit integers up to and including $n$ whose digit sum squared is equal to the integer in question;

    2. and all positive three digit integers up to and including $n$ whose digit sum cubed is equal to the integer in question.

    The digit sum of an integer $n$ is found by taking each digit of $n$ and adding them all together.

Input

First, the input for part one will be provided: Zero or more integers will appear in the input, each on its own line, followed by a line containing only a q or a Q, which indicates the repetition should stop.

Then, the input for part two follows: One line containing the integer $n$.

You may assume that each integer in the input will be between $10$ and $999$.

Output

For each integer input in the first part, the program outputs yes if the integer has $10$ or more positive divisors, otherwise it outputs no.

Then the program outputs the integers found in part two in ascending order, each on its own line.

The program must handle input and output in the correct order. In other words, it cannot read the next integer before producing the output for the previous one.

Read Sample Interaction 1 Write
24
no
48
yes
88
no
96
yes
q
999
81
512

Please log in to submit a solution to this problem

Log in