If you have trouble deciding if it is leap year the following (might) help you:
if year modulo 4 is 0
then
if year modulo 100 is 0
then
if year modulo 400 is 0
then
is_leap_year
else
not_leap_year
else is_leap_year
else not_leap_year
OR
is_leap_year = ( year modulo 4 is 0 ) and ( ( year modulo 100 is not 0 ) or ( year modulo 400 is 0 ) )
Basically if the year divides with no remainder by 4 but not 100 except if it divides by 400 then it is a leap year. (2000 and 2400 leap years, not 2100 or 2200).
No comments:
Post a Comment