Help:=proc():print(`GR(A)`):end: with(SolveTools): #GR(A): inputs the max. capital A, #outputs the list [E[1],E[2], ..., E[A-1]] #where E[i] is the expected number of tosses #until the end if currently at i GR:=proc(A::posint) local E1,i,eq,var,sol1: if A=1 then RETURN([]): fi: eq:={E1[0]=0,E1[A]=0}: var:={seq(E1[i],i=0..A)}: eq:=eq union {seq(E1[i]-(E1[i-1]+E1[i+1])/2-1=0,i=1..A-1)}: sol1:=Linear(eq,var): [seq(subs(sol1,E1[i]),i=1..A-1)]: end: