function [flops] = hw4afn(n,N,A,b,x0)

   flops = 0;

   for k = 1:N
      for i = 1:n
         xN(i,1) = b(i);
         for j = 1:n
            if j ~= i
               xN(i,1) = xN(i,1)-A(i,j)*x0(j,1);
               flops = flops+2;
            end
         end
         xN(i,1) = xN(i,1)/A(i,i);
         flops = flops+1;
      end

      for i = 1:n
         x0(i,1) = xN(i,1);
      end
   end
end
