3 ms·
I mean, that contradiction is also in the first two rules. It's a leap year if it's divisible by 4, but not if it's divisible by 100, so what about 200? Best t
by SamBam 3y ago
I mean, that contradiction is also in the first two rules. It's a leap year if it's divisible by 4, but not if it's divisible by 100, so what about 200?
Best to describe it as a flowchart
* Is the year divisible by 400? YES -> Leap year
* NO -> Is the year divisible by 100? YES -> Not leap year
* NO -> Is the year divisible by 4? YES -> Leap year
* NO -> Not leap year
- stoltzmann 3y agoPedantic but this drives me nuts - this algorithm has to do 3 divisions for almost every year. If you flip it upside down, it's significantly faster. * Is the year divisible by 4? NO -> not leap year * YES -> Is the year divisible by 100? NO -> leap year * YES -> Is the year divisible by 400? NO -> not leap year * YES -> leap year This way you do only 1 division for 75% of years.
- daveguy 3y agoFortunately, it's not a very big N. ;)