Help:=proc() print(`GR(A)`): end: with(SolveTools): # #GR(A): inputs the max capital A,B # outputs the list [E[1,1],E[1,2],..,E[1,B-1],...,E[A-1,1],..E[A-1,B-1] where E[i] is the expected number of tosses #until the end if currently at i GR:=proc(A::posint,B::posint) local E,i,eq,var,sol1: if A=1 or B=1 then RETURN([]): fi: eq:={seq(E[0,i]=0,i=0..B)} union {seq(E[i,0]=0,i=0..A)} union {seq(E[A,i]=0,i=0..B)} union {seq(E[i,B]=0,i=0..A)}: var:={seq(seq(E[i,j],i=0..A),j=0..B)}: eq:=eq union {seq(seq(E[i,j]-(E[i-1,j]+E[i+1,j]+E[i,j-1]+E[i,j+1])/4-1=0,i=1..A-1),j=1..B-1)}: var,eq: sol1:=Linear(eq,var): [seq(seq(subs(sol1,E[i,j]),i=1..A-1),j=1..B-1)]: end: #L := [[[2], 1], [[3], 2], [[4], 11/4], [[5], 10/3], [[6], 99/26], [[7], 122/29], [[8], 619/136], [[9], 4374/901], [[10], 187389/36562], [[11], 482698/89893], [[12], 11031203/1972460], [[13], 33386106/5758715], [[14], 32723853563/5465775058], [[15], 139832066/22687425], [[16], 150236161755/23740281872], [[17], 633573154269934/97725875584681], [[18], 5755694771977/868245469442], [[19], 189378719187729770/27985118605791989], [[20], 509943025510535499/73925970047640596]] ------=_20050228151110_50146--