function [flops] = hw1bfn(n, A, B, x)

   flops = 0;

   for i = 1:n
      for j = 1:n
         C(i,j) = 0;
         for k = 1:n
            C(i,j) = C(i,j)+A(i,k)*B(k,j);
            flops = flops+2;
         end
      end
   end

   for i = 1:n
      y(i,1) = 0;
      for j = 1:n
         y(i,1) = y(i,1)+C(i,j)*x(j,1);
         flops = flops+2;
      end
   end

%   for i = 1:n
%      for j = 1:n
%         C(i,j) = A(i,1)*B(1,j);
%         flops = flops+1;
%         for k = 2:n
%            C(i,j) = C(i,j)+A(i,k)*B(k,j);
%            flops = flops+2;
%         end
%      end
%   end
%
%   for i = 1:n
%      y(i,1) = C(i,1)*x(1,1);
%      flops = flops+1;
%      for j = 2:n
%         y(i,1) = y(i,1)+C(i,j)*x(j,1);
%         flops = flops+2;
%      end
%   end

end
