% Declare the relevant parameters

tol=0.0001;
nmax=10;
p0=1.5;
false = 1;
true = 0;
finish = false;
iteration = 0;

while (finish == false & iteration <= nmax );

   iteration = iteration + 1;
   p=g(p0);

   if (abs(p-p0)/abs(p) < tol ) ;
      finish = true;
   else
      p0=p;
   end

  fprintf(1,'result after iteration number %3d ',iteration);
  fprintf(1,'is %15.7e \n',p);

end

if (iteration < nmax);

  fprintf(1,'converged after iteration number %3d ',iteration);
  fprintf(1,'is %15.7e \n',p);

else

  fprintf(1,'no convergence after iteration number %3d ',nmax);

end
