Java 10, 195 194 184 182 bytes
n->{var L=new java.util.Stack();int i=1,k,x,s,r=0;for(;i++<n;){for(k=1;i%++k>0;);if(k==i)L.add(i);}for(x=L.size(),i=0;i<x;)for(k=i++,s=0;k<x;r+=s==n?1:0)s+=(int)L.get(k++);return r;}
-1 byte thanks to @ceilingcat.
-10 bytes thanks to @SaraJ.
Try it online.
Explanation:
n->{ // Method with integer as both parameter and return-type
var L=new java.util.Stack();
// List of primes, starting empty
int i=1,k,x,s, // Temp integers
r=0; // Result-counter, starting at 0
for(;i++<n;){ // Loop `i` in the range [2, `n`]
for(k=1; // Set `k` to 1
i%++k>0;); // Inner loop which increases `k` by 1 before every iteration,
// and continues as long as `i` is not divisible by `k`
if(k==i) // If `k` is now still the same as `i`; a.k.a. if `i` is a prime:
L.add(i);} // Add the prime to the List
for(x=L.size(), // Get the amount of primes in the List
i=0;i<x;) // Loop `i` in the range [0, amount_of_primes)
for(s=0, // (Re)set the sum to 0
k=i++;k<x; // Inner loop `k` in the range [`i`, amount_of_primes)
r+=s==n? // After every iteration, if the sum is equal to the input:
1 // Increase the result-counter by 1
: // Else:
0) // Leave the result-counter the same by adding 0
s+=(int)L.get(k++);
// Add the next prime (at index `k`) to the sum
return r;} // And finally return the result-counter
It's basically similar as the Jelly or 05AB1E answers, just 190 bytes more.. XD
Here a comparison for each of the parts, added just for fun (and to see why Java is so verbose, and these golfing languages are so powerful):
- Take the input: (Jelly: 0 bytes) implicitly; (05AB1E: 0 bytes) implicitly; (Java 10: 5 bytes)
n->{}
- Create a list of primes in the range
[2, n]
: (Jelly: 2 bytes) ÆR
; (05AB1E: 2 bytes) ÅP
; (Java 10: 95 bytes) var L=new java.util.Stack();int i=1,k,x,s,r=0;for(;i++<n;){for(k=1;i%++k>0;);if(k==i)L.add(i);}
- Get all continuous sub-lists: (Jelly: 1 byte)
Ẇ
; (05AB1E: 1 byte) Œ
; (Java 10: 55 bytes) for(x=L.size(),i=0;i<x;)for(k=i++;k<x;)
and (int)L.get(k++);
- Sum each sub-list: (Jelly: 1 byte)
§
; (05AB1E: 1 byte) O
; (Java 10: 9 bytes) ,s
and ,s=0
and s+=
- Count those equal to the input: (Jelly: 1 byte)
ċ
; (05AB1E: 2 bytes) QO
; (Java 10: 15 bytes) ,r=0
and r+=s==n?1:0
- Output the result: (Jelly: 0 bytes) implicitly; (05AB1E: 0 bytes) implicitly; (Java 10: 9 bytes)
return r;