Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Leap-year/REBOL/leap-year.rebol
Normal file
15
Task/Leap-year/REBOL/leap-year.rebol
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
leap-year?: func [
|
||||
{Returns true if the specified year is a leap year; false otherwise.}
|
||||
year [date! integer!]
|
||||
/local div?
|
||||
][
|
||||
either date? year [year: year/year] [
|
||||
if negative? year [throw make error! join [script invalid-arg] year]
|
||||
]
|
||||
; The key numbers are 4, 100, and 400, combined as follows:
|
||||
; 1) If the year is divisible by 4, it’s a leap year.
|
||||
; 2) But, if the year is also divisible by 100, it’s not a leap year.
|
||||
; 3) Double but, if the year is also divisible by 400, it is a leap year.
|
||||
div?: func [n] [zero? year // n]
|
||||
to logic! any [all [div? 4 not div? 100] div? 400]
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue