You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

a)

function res = monthsWithFriday13 ( year )
res = zeros (1 ,12) ;
for month =1:12
monthCalendar = getCalendar (year , month );
% Fredag 13. kan kun vaere i 3. uken i en maaned
if monthCalendar (3, 5) == 13
res ( month ) = 1;
end
end
end

 

b)

function year = maxFridays13()
year = 0;
top = 0;
for i = 1900:2015
    temp = sum(monthsWithFriday13(i) );
    if temp > top
        year = i;
        top = temp;
    end
end
end
  • No labels