Let f(m,n) is B's cakes. We can get following recursive function: f(m,n)=1/2(1+f(m-1,n)+f(m-1,n-1)) f(m,m)=m/2,f(1,0)=0. Most recursive functions can't be simplified,but this can...if you have time.