Given an integer n
, return the number of ways that n can be written as a list of prime numbers. For example, 2323
can be written as (2,3,23)
, (23,23)
or (2,3,2,3)
or (23,2,3)
, so you would output 4
. If it can not be written in this way, you should output 0
.
A prime number such as 019
or 00000037
is a valid prime for this problem.
Test cases:
5 -> 1
55 -> 1
3593 -> 4 (359 and 3, or 3 and 593, or 3 and 59 and 3, or 3593)
3079 -> 2 (3 and 079, or 3079)
119 -> 0
5730000037 -> 7 (5,7,3,000003,7, 5,7,3,0000037, 5,73,000003,7, 5,73,0000037, 5,73000003,7, 5,7,30000037, 5730000037)
0-> undefined (you do not have to handle this case)
This is code-golf, so the shortest answer in bytes in each language wins!
Edit: now I know why I should use the sandbox next time