Which is the next year after 2025 that will have exactly the same calendar as 2025?
2031. Two years share a calendar when they start on the same weekday and are both leap or both non-leap. Adding odd days from 2025 onward (1, 1, 1, 2, 1, 1) reaches 7 after 2030, so 2031 starts on the same day as 2025 (Wednesday) and is also a non-leap year.
Explain it simply
A calendar repeats when the new year starts on the same weekday and has the same number of days. A normal year pushes the next year's start by 1 weekday; a leap year pushes it by 2. Keep adding those shifts until the total is a multiple of 7, then check the leap status matches.
Example
Question: Next year with the same calendar as 2025.
2025 is not a leap year and starts on a Wednesday.
| Year | Odd days | Running total |
|---|---|---|
| 2025 | 1 | 1 |
| 2026 | 1 | 2 |
| 2027 | 1 | 3 |
| 2028 (leap) | 2 | 5 |
| 2029 | 1 | 6 |
| 2030 | 1 | 7 |
The total hits 7 after 2030, so 2031 starts on a Wednesday. 2031 is not a leap year, so its calendar matches 2025. Answer: 2031.
const isLeap = y => (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0;
let shift = 0, y = 2025;
do { shift += isLeap(y) ? 2 : 1; y++; } while (shift % 7 !== 0 || isLeap(y) !== isLeap(2025));
console.log(y); // Output: 2031For a leap year the gap is usually 28 years. For example, 2024 repeats in 2052.
What to say in the interview
"I add one odd day per normal year and two per leap year. The total reaches 7 after 2030, so 2031 starts on the same weekday, and it's non-leap like 2025. So 2031."
Common mistakes
- Stopping when the weekday matches without checking that both years are leap or both non-leap.
- Adding the odd days of the target year itself.