Today I'm featuring this Wiki article:
Here is the overview from that article:
For example, let’s say you want to create a program that checks whether a given year’s a leap year or not. It’s a leap year if the year’s evenly divisible by 4. But if it’s evenly divisible by 100, then it also needs to be evenly divisible by 400. The Figure shows you a flowchart of what you’d need to test for.
Figure: A flowchart for checking if a given year’s a leap year
Here are three examples of these rules:
- Year 2020 is divisible by 4. Since it isn’t evenly divisible by 100, it’s a leap year!
- Year 2100 is divisible by 4. Because it’s evenly divisible by 100, you need to check its divisibility by 400. Since it isn’t evenly divisible by 400, it’s not a leap year.
- Year 2400 is divisible by 4. Because it’s evenly divisible by 100, you’ll need to check its divisibility by 400. Since it’s evenly divisible by 400, it’s a leap year!
For the latest version, you can head to the Wiki article. You can also get the code, output examples, and an explanation of what the code does:
Have a Small and Basic New Year!
- Ninja Ed