Leap year

From Rosetta Code
Revision as of 18:52, 20 July 2010 by rosettacode>Mwn3d (Added Java, fix "See Also" heading, TOC will appear automatically when it needs to)

Determine whether a given year is a leap year.

See Also

Java

<lang java>public static boolean isLeapYear(int year){

   if(year % 100 == 0) return year % 400 == 0;
   return year % 4 == 0;

}</lang>

Python

<lang python>def is_leap_year(year):

   if year % 100 == 0:
       return year % 400 == 0
   return year % 4 == 0

</lang>