Leap year

Article

May 19, 2022

A leap year is a year that has 366 days, unlike other years that have 365 days. The reason for that is the harmonization of the calendar year with the astronomical year, so that the New Year does not fall in summer and the grapes ripen in December or January. Thus, the month of February, which otherwise has 28 days, has 29 days in the leap year. Non-criminal years are called simple years. It is a leap year every 4 years, except if it is divisible by 100 and not by 400. The cycle of the Gregorian calendar lasts 400 years, after which the date schedule is repeated. 2000 and 2400 are (all of this refers to the Gregorian calendar).

Algorithm

Based on the rules that determine the leap year, an algorithm can be formed, which gives a positive answer if the following set of conditions is met: number of years divisible by four, and one of the following two applies: the number of the year is not divisible by 100 the number of the year is divisible by 400

Implementation

Various implementations of this function are possible in existing programming languages. For example. The C-function, which returns 1 if the year is a leap year, and otherwise 0, would read: In Pascal, the function for determining the leap year looks like this: In Javascript, the leap year function looks like this:

Reference