Probabilistic approach puzzle A few hours earlier, I got this puzzle:


  Suppose, you toss a coin n times, then what is the probability of getting m number of heads? ( where m belongs to the set of all prime numbers)


For instance, take n = 2, then
SS = { HH, HT, TH, TT }

So, output is 1/4 (for HH case)

Then, for n = 3,
SS = { HHH, HHT, HTH, THH, HTT, THT, TTH, TTT }

So, output is (1 + 3)/8 (for 3 H's case and 2 H's cases respectively)

Input: n ( an integer, 0 &lt;= n &lt;= 1000 )
Output: The probability (in any distinguishable form, i.e., decimal, exponential, fraction, etc)

This is a code-golf, so fewest bytes would win!
Wolfram Language (Mathematica), 33 bytes

Uses Binomial and outputs ,really fast, fractions   

    

Tr@Binomial[#,Prime@Range@#]/2^#&amp;


Try it online!

The original code according to my formula was 

Tr@Binomial[#,Prime@Range@PrimePi@#]/2^#&amp;    


but, as @attinat commented, instead of searching all Primes &lt; n  we can
search the first n primes because every prime > n returns zero binomial.
In this way we save 8 bytes     

Here is also the graph of the first 1000 cases which looks pretty cool