Day of the week: Difference between revisions

Modula-3 (and I finally remembered to log in :))
(Modula-3 (and I finally remembered to log in :)))
Line 296:
Sun Dec 25 00:00:00 CST 2112
Sun Dec 25 00:00:00 CST 2118</pre>
 
=={{header|Modula-3}}==
{{trans|Fortran}}
<pre>
MODULE Yule EXPORTS Main;
 
IMPORT IO, Fmt;
 
PROCEDURE DayOfWeek(d, m, y: INTEGER): INTEGER =
VAR j := y DIV 100;
k := y MOD 100;
BEGIN
RETURN (d + (m + 1) * 26 DIV 10 + k + k DIV 4 + j DIV 4 + 5 * j) MOD 7;
END DayOfWeek;
 
BEGIN
IO.Put("25th of December is a Sunday in ");
FOR year := 2008 TO 2121 DO
IF DayOfWeek(25, 12, year) = 1 THEN
IO.Put(Fmt.Int(year) & " ");
END;
END;
IO.Put("\n");
END Yule.
</pre>
 
Output:
<pre>
25th of December is a Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
</pre>
 
=={{header|Objective-C}}==
Anonymous user