Most years have 52 weeks, some have 53, according to ISO8601.



Task

Write a function which determines if a given year is long (53 weeks) or not, and demonstrate it.




MODULE LongYear;
FROM InOut IMPORT WriteCard, WriteLn;
 
VAR year: CARDINAL;
 
PROCEDURE isLongYear(year: CARDINAL): BOOLEAN;
    PROCEDURE p(year: CARDINAL): CARDINAL;
    BEGIN
        RETURN (year + year DIV 4 - year DIV 100 + year DIV 400) MOD 7;
    END p;
BEGIN
    RETURN (p(year) = 4) OR (p(year-1) = 3);
END isLongYear;
 
BEGIN
    FOR year := 2000 TO 2100 DO
        IF isLongYear(year) THEN
            WriteCard(year, 4);
            WriteLn;
        END;
    END;
END LongYear.