Win a copy of Rust Web Development this week in the Other Languages forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Tim Cooke
• Campbell Ritchie
• Ron McLeod
• Liutauras Vilda
• Jeanne Boyarsky
Sheriffs:
• Junilu Lacar
• Rob Spoor
• Paul Clapham
Saloon Keepers:
• Tim Holloway
• Tim Moores
• Jesse Silverman
• Stephan van Hulst
• Carey Brown
Bartenders:
• Al Hobbs
• Piet Souris
• Frits Walraven

# Leap Year

Greenhorn
Posts: 6
• Number of slices to send:
Optional 'thank-you' note:
I would like to question the validity of this statement made about Assgn 1.3.
"The tricky thing here is that a leap year occurs:
on every year that is evenly divisible by 4
except every year that is evenly divisible by 100
except every year that is evenly divisible by 400. "
Wouldn't that mean that the year 2000 wasn't a leap year?
2000/4 = 500
2000/100 = 20
2000/400 = 5
Please set me straight if I am misinterpreting this pseudo code.

Ranch Hand
Posts: 63
• Number of slices to send:
Optional 'thank-you' note:
Hello Ryan
divisible by 4 = leap year!
except divisible by 100 = not a leap year
except divisible by 400 = leap Year!
If you consider the two "excepts" as a double negative (i.e. if it's divisable by 100 but NOT divisible by 400) all within the "divisible by 4" group, being divisible by 400 would then be a leap year.
This still may be a bit confusing, but I can't think of a better way to say this....
Pat B.

Bartender
Posts: 4121
• Number of slices to send:
Optional 'thank-you' note:
If only there were an easy way to do grouping with parentheses in natural language...
x = year is divisible by 4
y = year is divisible by 100
z = year is divisible by 400
Year is a leap year = ( x && !y | | ( x && ( y && z ) ) )
A better way to term the requirement in natural language is : "A year is a leap year if it divisible by 4. If a year that is divisible by 4 is also divisible by 100, it is not a leap year. However, if a year is divisible by 4, 100, and 400, then it it a leap year."
By this assertion 2000 was a leap year...
HTH,
-Nate

Rancher
Posts: 1449
• Number of slices to send:
Optional 'thank-you' note:
The second except relates to the first, ie, if a year that is evenly divisible by 4 and is evenly divisible by 100 is also evenly divisible by 400 then it is a leap year.
So 2000 was a leap year but 1900 was not since 1900 is evenly divisible by 4 & 100 but not by 400.
John

Ryan Ryszka
Greenhorn
Posts: 6
• Number of slices to send:
Optional 'thank-you' note:
Thanks for all the help and the quick response!!! I think I have it now.

Sheriff
Posts: 9109
12
• Number of slices to send:
Optional 'thank-you' note:
You can also see an example/explanation in the Style Guide

[This message has been edited by Marilyn deQueiroz (edited January 18, 2001).]