N=100;
h=1/N;
M=10000;
Z=randn(M,N);
S=ones(M,N+1);

B=2;
for i=1:N
    S(:,i+1)=S(:,i).*exp(0.1*h+0.5*sqrt(h)*Z(:,i));
end
test=(S(:,N+1)>=1).*(max(S,[],2)<=B);
ret=exp(-0.1)*(S(:,N+1).*(test==1) + (test==0));
mean(ret)
std(ret)/sqrt(M)

% sample results
% B=1.8  0.9837    0.0015
% B=2    1.0229    0.0020
% B=2.3  1.0718    0.0026
% B=1.9  1.0012    0.0018