Re: Leap Years

new topic     » goto parent     » topic index » view thread      » older message » newer message

Joshua Milligan wrote:
>
> Does anyone have an algorithm for determining whether or not a given year is
> a leap year? (Sorry, this has probably been asked and answered before.)
>
> Thanks for your help,
> Joshua Milligan

------------------------------------------------------------------------------
-- leap year is any year divisible by 4, as long as...
-- it is not divisible by 100 unless it's divisible by 400
-- as well.

function leap_year (atom year)
-- returns 1 for leap years, 0 for non-leap years
    return (remainder(year, 4) = 0) and
           (remainder(year, 100) != 0) or
           (remainder(year, 400) = 0)
end function
------------------------------------------------------------------------------

Hope this helps,
Christopher D. Hickman

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu