Consider a situation where (n-1) coins are thrown together, and the nth coin is discarded and takes into account mutual independence.
Combine the probabilities of simpler cases to get P (1..n, k) (where P (1..n, k) is the probability of getting exactly k goals with n coins)
Then apply this rule and fill in all the cells in the NxK table
Edit:
There are two possible ways to get exactly k goals with n coins -
a) if (n-1) coins have k goals, and the Nth coin has a tail, and
b) if (n-1) coins have k-1 goals and the Nth head
So
P (n, k) = P (n-1, k) * (1 - p [n]) + P (n-1, k-1) * p [n]
source share