Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

leap year

// works in C, C++, C#, Java, JavaScript, and other C-like languages

// optimal technique
if (((year & 3) == 0 && ((year % 25) != 0) || (year & 15) == 0)) {
  // leap year
}

// classic technique
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
	// leap year
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #leap #year
ADD COMMENT
Topic
Name
6+4 =