# Expected number of steps till a random walk hits a or -b. [duplicate]

This question already has an answer here:

On wikipedia I read that the expected number of steps till a 1D simple random walk hits either $a$ or $-b$ is equal to $ab$. (I have seen this result also on other websites.) However, no proof or further reference is given. Could someone please explain how they arrived at this result?

Thanks in advance, Claus

-

## marked as duplicate by Did probability StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Oct 31 '15 at 12:41

Have a look at math.stackexchange.com/questions/288298/… – coffeemath Feb 18 '13 at 16:16

The expected time $t_x$ to hit either boundary starting at $x$ satisfies the recurrence
$$t_x=1+\frac12\left(t_{x-1}+t_{x+1}\right)\;.$$
The general solution of this second-order linear recurrence is $t_x=-x^2+mx+n$, and you can easily check that $t_x=(a-x)(x+b)$ is of this form and satisfies the boundary conditions $t_a=t_{-b}=0$; thus $t_0=(a-0)(0+b)=ab$.