Computer Science, asked by madagonishivani3, 8 months ago

Your task is to complete a function
"count_heads() that takes two inputs N
and R. The function should return the
probability of getting exactly R heads on
N successive tosses of a fair coin. A fair
coin has equal probability of landing a
head or a tail (i.e. 0.5) on each toss.
For example,
for the arguments provided as follows:
11
The function should return
0.500000
Another example,
for the arguments provided as follows:
43
The function should return
0.250000
ining for Test 00:26:26​

Answers

Answered by kirangusain84
3

Answer:

Probability of getting K heads in N coin tosses

Given two integers N and R. The task is to calculate the probability of getting exactly r heads in n successive tosses.

A fair coin has an equal probability of landing a head or a tail on each toss.

Examples:

Input : N = 1, R = 1

Output : 0.500000

Input : N = 4, R = 3

Output : 0.250000

Similar questions