-->
当前位置:首页 > 题库

PROGRAMMING:Sum of continuous prime numbers

Luz5年前 (2021-05-10)题库391
Some positive integers can be decomposed into the sum of one or more consecutive primes. Given a positive integer, how many possible decomposition methods are there? For example, 53 can be broken down into 5 + 7 + 11 + 13 + 17 and 53. There are three ways to decompose integer 41: 2 + 3 + 5 + 7 + 11 + 13, 11 + 13 + 17 and 41. There is only one way to decompose integer 3, namely 3. The integer 20 cannot be decomposed into the sum of continuous primes. Note: when decomposing an integer, the prime number must be continuous, so 7 + 13 and 3 + 5 + 5 + 7 are not effective decomposing ways of 20, because there is a prime number 11 between 7 and 13, and 5 appears repeatedly in 3 + 5 + 5 + 7< br>
Please write a program, for a given positive integer, output its effective decomposition method.
###Input:
Each row gives a positive integer with a value between 2 and 10000, including 2 and 10000. When 0 is encountered, it means the end of input, and 0 does not need to be decomposed.
###Output:
The output consists of multiple lines. Each line corresponds to the input line (except the line ending with 0 in the input). The value of this line corresponds to the number of effective prime factorization of integers in the input, and there shall be no redundant sign at the end of the line.
###Input example:
```in
two
three
seventeen
forty-one
twenty
six hundred and sixty-six
twelve
fifty-three
0
```
###Output example:
```out
one
one
two
three
0
0
one
two
```






answer:If there is no answer, please comment