function [x] = hw8afn(n,Q,R,b)

   for i = 1:n
      c(i,1) = 0;   
      for j = 1:n
         c(i,1) = c(i,1)+Q(j,i)*b(j,1);
      end
   end

   for i = n:-1:1
      x(i,1) = c(i,1);
      for j = i+1:n
         x(i,1) = x(i,1)-R(i,j)*x(j,1);
      end
      x(i,1) = x(i,1)/R(i,i);
   end

end
