New Reply

Simple test to see if year is a leap year

 
Share Thread
Jun26-12, 01:01 PM   #1
 

Simple test to see if year is a leap year


I just stumbled across this on my own. I find that all leap years in the current calendar are multiples of 16. Therefore, to see if a year is a leap year, one need only to divide the year by 16 and see if there is a remainder. If so, the year is not a leap year. If not, the year is a leap year. Note that this only works for dates in the Gregorian calendar, which was created in 1582 AD but was not universally adopted for a few years. So you'll need to know when the country of interest adopted the Gregorian calendar.
PhysOrg.com mathematics news on PhysOrg.com

>> Pendulum swings back on 350-year-old mathematical mystery
>> Bayesian statistics theorem holds its own - but use with caution
>> Math technique de-clutters cancer-cell data, revealing tumor evolution, treatment leads
Jun26-12, 01:09 PM   #2
 
I don't think this is correct. Any year divisible by 4 is a leap year unless it is divisible by 100. For example 2004 and 2008 were leap years and neither one is divisible by 16.
Jun26-12, 01:14 PM   #3
 
I don't follow your logic. 2012 is a leap year. I get 125.75 when I divide 2012 by 16.
Jun26-12, 01:25 PM   #4
 

Simple test to see if year is a leap year


Iirc a year is leap if it is divisible by four, unless it ends in two zeros then it must be divisible by sixteen.
Jun26-12, 02:11 PM   #5
D H
 
Mentor
Quote by phyzguy View Post
Any year divisible by 4 is a leap year unless it is divisible by 100.
Almost. Years that are divisible by 400 are also leap years. One way to write this:
[tex](N = 0\mod 4) \wedge ((N \ne 0 \mod 100) \vee (N = 0 \mod 400))[/tex]

The test for whether a year is a leap year can be written in a number of ways, but it will always involve three modulus calculations. For example, this also works:
[tex](N = 0\mod 16) \vee ((N = 0 \mod 4) \wedge (N \ne 0 \mod 25))[/tex]
Jun26-12, 02:20 PM   #6
 
I thought this pseudocode from wikipedia was useful.

if year modulo 400 is 0 then
is_leap_year
else if year modulo 100 is 0 then
not_leap_year
else if year modulo 4 is 0 then
is_leap_year
else
not_leap_year

It helps to see how 2000 was a leap year but 1900 was not.
Jun26-12, 09:06 PM   #7
 
Quote by Ynaught? View Post
I don't follow your logic. 2012 is a leap year. I get 125.75 when I divide 2012 by 16.
Got it. But the remainder is 3/4.

Updated: If there is a remainder, and its denominator is 4, then the year is a leap year.
Jun26-12, 10:57 PM   #8
D H
 
Mentor
Quote by moonman239 View Post
Got it. But the remainder is 3/4.

Updated: If there is a remainder, and its denominator is 4, then the year is a leap year.
No! That would make 1900 a leap year, which it wasn't. It's a three-way test. See posts #5 and 6.
Jun27-12, 12:09 AM   #9
 
Recognitions:
Homework Helper Homework Help
Science Advisor Science Advisor
An interesting consequence of the leap year rules is that the 13th of the month falls on a Friday more often than 1/7.
Jun27-12, 12:20 AM   #10
 
Recognitions:
Homework Helper Homework Help
Quote by Ynaught? View Post
I get 125.75 when I divide 2012 by 16.
Quote by moonman239 View Post
Got it. But the remainder is 3/4.
I thought the remainder upon dividing 2012 by 16 is 12, not 3/4.
New Reply

Tags
leap year

Similar discussions for: Simple test to see if year is a leap year
Thread Forum Replies
16 year old solves 300 year old problem set by Isaac Newton General Physics 43
C++ Leap Year Function Engineering, Comp Sci, & Technology Homework 4
C++: Leap Year Engineering, Comp Sci, & Technology Homework 2