Find probability that a player wins when probabilities of hitting the target are given | Function to return the probability of the winner ; Driver Code ; Will print 9 digits after the decimal point
< ? php function find_probability ( $ p , $ q , $ r , $ s ) { $ t = ( 1 - $ p / $ q ) * ( 1 - $ r / $ s ) ; $ ans = ( $ p / $ q ) / ( 1 - $ t ) ; return $ ans ; } $ p = 1 ; $ q = 2 ; $ r = 1 ; $ s = 2 ; $ res = find_probability ( $ p , $ q , $ r , $ s ) ; $ update = number_format ( $ res , 7 ) ; echo $ update ; ? >