|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||0||0||0||0.000%|
The digital root of a number is found by adding together the digits that make up the number. If the resulting number has more than one digit, the process is repeated until a single digit remains.
Your task in this problem is to calculate a variation on the digital root — a prime digital root. The addition process described above stops when there is only one digit left, but will also stop if the original number, or any of the intermediate numbers (formed by addition) are prime numbers. If the process continues and results in a single digit that is not a prime number, then the original number has no prime digital root.
An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself.
Here are examples of prime digital roots:
The input will contain a single integer on each line in the range 0 to 999999 inclusive. The end of the input will be indicated by the value 0.
If the input number has a prime digital root, then the input number must be output right aligned with a field width of 7. It must be followed by a single space, and then by the calculated prime digital root also right aligned with a field width of 7.
If the input number has no prime digital root, then the input number should be output as defined above followed by 4 spaces followed by the word none (in lowercase). The terminating zero should not be output.
1 3 4 11 642 128 886 0
1 none 3 3 4 none 11 11 642 3 128 11 886 none