Leap year: Difference between revisions

m
simplify
m (even more concise)
m (simplify)
Line 2,738:
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let is_leap_year ~year =
ifyear mod (if year mod 100 = 0 then 400 else 4) = 0</syntaxhighlight>
then (year mod 400) = 0
else (year mod 4) = 0</syntaxhighlight>
Using Unix Time functions:
<syntaxhighlight lang="ocaml">let is_leap_year ~year =
Line 3,069 ⟶ 3,067:
or
<syntaxhighlight lang="python">def is_leap_year(year):
return not year % (4 if year % 100 ==else 0:400)</syntaxhighlight>
return year % 400 == 0
return year % 4 == 0</syntaxhighlight>
Asking for forgiveness instead of permission:
<syntaxhighlight lang="python">import datetime
559

edits