Premium problem107. First Success on Attempt k

Easy Locked

An operation succeeds with probability p each independent try. Return the probability the first success happens on attempt exactly k.

P(K=k)=(1−p)k−1pP(K = k) = (1-p)^{k-1}p

Input

p = 0.3
k = 3

Output

0.14699999999999996

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)