The modern (Gregorian) calendar and the Julian calendar.
The Gregorian calendar is based entirely on the Julian calendar.
The modern calendar that is currently in use, also called the Gregorian or civil calendar, is based entirely on the Julian calendar, which was introduced by the Roman Emperor Julius Caesar, in 45 BC.
The Julian calendar featured a year comprized of 12 months, being a 365 days a year calendar, with an intercalary day inserted every fourth year at the end of month of February to make an average year of 365.25 days.
But, as we have already seen above, because the length of the astronomical year is actually ≈ 365.242216 days, the Julian calendar year was longer by about 11 minutes and 14 seconds than the astronomical year. Perhaps this doesn't seem a lot, but over time it added up, until in the 16th century, after 1627 years from its adoption, the vernal equinox (* see note below) was falling around March 11th instead of March 21st (a 10 days shift).
* Note: Equinox.
Day and night are of equal duration.
Equinox = the moment when day and night are of approximately equal duration all over the planet, the northern and southern hemispheres being equally illuminated. In this moment the plane of Earth's equator passes through the center of the Sun's disk.
The equinox occurs twice a year: once around March 20th (the vernal equinox, conventionally marks the beginning of spring in the nortern hemisphere while for the southern hemisphere it is the autumnal equinox, that marks the beginning of autumn) and once around September 23rd (the autumnal equinox, conventionally marks the beginning of autumn in the nortern hemisphere while for the southern hemisphere it is the vernal equinox, that marks the beginning of spring).
The modern Gregorian calendar and the adjustment of the Julian calendar.
The only difference between the two calendars: a year that is evenly divisible by 100 is a leap year only if it is evenly divisible by 400 as well.
In 1582, at February 24th, by papal bull Inter gravissimas, Pope Gregory XIII (the 13th) commissioned the adjustment of the Julian calendar, that was in use at that time, in short dully leaping from the date of October 4th (Thursday) not to the date of October 5th (Friday) as it would had been normal, but to the date of October 15th (Friday), dully synchronizing the calendar year with the astronomical one.
Also, as important as the above synchronization, it was the change on the rule for the intercalary day, so that the kind of discrepancies (differences) generated by the Julian calendar would not happen, well, at least not for the next 3300 years.
Therefore the algorithm ended up with the leap year rule, as presented in the above sections. This new rule, whereby a century year (one that is evenly divisible by 100) is a leap year only if it's also evenly divisible by 400, is the sole feature that distinguishes the Gregorian calendar from the Julian calendar (added on top of the previous rule of years being evenly divisible by 4).