https://www.geeksforgeeks.org/probability-reaching-point-2-3-steps-time/
A person starts walking from position X = 0, find the probability to reach exactly on X = N if she can only take either 2 steps or 3 steps. Probability for step length 2 is given i.e. P, probability for step length 3 is 1 – P.
Examples :
Input : N = 5, P = 0.20 Output : 0.32 Explanation :- There are two ways to reach 5. 2+3 with probability = 0.2 * 0.8 = 0.16 3+2 with probability = 0.8 * 0.2 = 0.16 So, total probability = 0.32.
It is a simple dynamic programming problem. It is simple extension of this problem :- count-ofdifferent-ways-express-n-sum-1-3-4