Digital Roots
#描述#
<p class="MsoNormal" style="text-autospace: none">
<span lang="EN-US" style="font-size: 12.0pt">The <i>digital root </i>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.</span></p>
<p class="MsoNormal" style="text-autospace: none">
<span lang="EN-US" style="font-size: 12.0pt">Your task in this problem is to
calculate a variation on the digital root - a <i>prime digital root</i>. 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.</span></p>
Examples of Prime Digital Roots:</span></p>
<p class="MsoNormal" align="left" style="text-align: left; text-indent: -24.0pt; text-autospace: none; margin-left: 24.0pt">
<span lang="EN-US" style="font-size: 12.0pt">1 is not a prime number, so 1 has
no prime digital root.</span></p>
<p class="MsoNormal" align="left" style="text-align: left; text-indent: -24.0pt; text-autospace: none; margin-left: 24.0pt">
<span lang="EN-US" style="font-size: 12.0pt">3 is a prime number, so the prime
digital root of 3 is 3.</span></p>
<p class="MsoNormal" align="left" style="text-align: left; text-indent: -24.0pt; text-autospace: none; margin-left: 24.0pt">
<span lang="EN-US" style="font-size: 12.0pt">4 is not a prime number, so 4 has
no prime digital root.</span></p>
<p class="MsoNormal" align="left" style="text-align: left; text-indent: -24.0pt; text-autospace: none; margin-left: 24.0pt">
<span lang="EN-US" style="font-size: 12.0pt">11 is a prime number, so the prime
digital root of 11 is 11.</span></p>
<p class="MsoNormal" style="text-indent: -24.0pt; text-autospace: none; margin-left: 24.0pt">
<span lang="EN-US" style="font-size: 12.0pt">642 is not a prime number, so
adding its digits gives 6 + 4 + 2 = 12. This is not a prime number, so adding
again gives 1 + 2 = 3. This is a prime number, so the prime digital root of 642
is 3.</span></p>
<p class="MsoNormal" style="text-indent: -24.0pt; text-autospace: none; margin-left: 24.0pt">
<span lang="EN-US" style="font-size: 12.0pt">128 is not a prime number, so
adding its digits gives 1 + 2 + 8 = 11. This is a prime number, so the prime
digital root of 128 is 11.</span></p>
<p class="MsoNormal" style="text-indent: -24.0pt; text-autospace: none; margin-left: 24.0pt">
<span lang="EN-US" style="font-size: 12.0pt">886 is not a prime number, so
adding its digits gives 8 + 8 + 6 = 22. This is not a prime number, so adding
again gives 2 + 2 = 4. This is not a prime number, so 886 has no prime digital
root.
#格式#
##输入格式##
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 and followed by a single space, then by the calculated prime digital root.
If the input number has no prime digital root, then the input number should be output as defined above followed by 1 space followed by the word none(in lowercase).
The terminating zero should not be output.
#样例1#
##样例输入1##
1
3
4
11
642
128
886
0
##样例输出1##
1 none
3 3
4 none
11 11
642 3
128 11
886 none
#限制#
1000ms
32768KB
#提示#
#来源#