News for hackers. Stuff that matters.
Re:Math and Puzzle Fans Find Magic in Martin Gardner's Legacy by bumbledraven on Saturday November 02, 2024 @02:37AM (#42024474)
It turns out that New Year's Day is a bit more likely to fall on Sunday than Saturday. To confirm, here's a bit of simple JavaScript that checks a complete 400-year cycle. You can run it in your browser's console:

  const counts = Array(7).fill(0);
  for (let year = 2000; year < 2400; year++) {
    counts[new Date(year, 0, 1).getDay()]++;
  }
  console.log(`Number of Saturdays: ${counts[6]}; Number of Sundays: ${counts[0]}`);
Output:

  Number of Saturdays: 56; Number of Sundays: 58
Note: getDay() returns 0 for Sunday and 6 for Saturday (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...).

There are no comments on this comment yet.