Today at work someone pointed out that since the month begins on a Friday this year and it’s a leap year, that this will be a rare February in which we will receive 3 paychecks in one month. The question that had us thinking was how rare this occurrence this actually is. 40 years? or perhaps every 28 years?
To attempt to solve this I figured I’d write a little script to run through the possibilities. Below is a quick script I threw together in PHP.
for ($i=1901; $i<2600; $i++) { if (date('L', mktime(0, 0, 0, 2, 1, $i))) { if (date('N', mktime(0, 0, 0, 2, 1, $i)) == 5) { echo $i . ' is a leap year and the 1st of the month is a Friday.'; } } }
It's pretty basic. It loops through the years 1901 through 2600. Then checks the if the current year that the loop is on happens to be a leap year. If it in fact is then it checks if the first of the February of that year happens to fall on a Friday. Finally if all that criteria is met it prints that year out.
The answer is that it will occur every 28 years.
3 replies on “Paycheck Riddle”
Um yeah, unless your pay cycle is to get paid on the second week of February, Therefore I still only get 2 pay check in February. So I will have to wait until May 08 to get 3 pay checks in one month.
That’s true about how your pay cycle falls to start February. However our debate assumed that if in fact the first of February was a pay day and if so how long until it could occur again, which the script did prove. Receiving 3 paychecks in months other than February while rare, is not nearly as rare as it occurring during the month of February as it usually consists of 28 days with the exception of a Leap Year when there’s 29 days.
That came out wrong, lets try again. Hangman….
__ __ __ __ __
__ __ __