% Control1_1.m
% Solution to problem 1 of control 1, Nov.2016
% J.M.Soler

clear
n = 100;
for i = 1:n
  for j = 1:n
    A(i,j) = floor(j/i);
    B(i,j) = ceil(i/j);
  end
end

m=floor(n/3);
for i = 1:m
  for j = 1:m
    C(i,j) = B(3*i,3*j)-A(3*i,3*j);
  end
  D(i) = C(i,m+1-i);
end

sum_D = sum(D)
sum_positive_C = sum(C(find(C>0)))
prod_C_multiple_13 = prod(C(find(C~=0 & mod(C,13)==0)))
