Cody

Problem 1268. Penny flipping - calculate winning probability (easy)

Two players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game.

Calculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.

Example:

Input: m = 1, n =1
Output: 0.50

Solution Stats

74.23% Correct | 25.77% Incorrect
Last solution submitted on Sep 30, 2016

Problem Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more