E.g. I'm using this formulas for calculating day of week (Julian calendar):
\begin{align} a & = \left\lfloor\frac{14 - \text{month}}{12}\right\rfloor\\ y & = \text{year} + 4800 - a \\ m & = \text{month} + 12a - 3 \end{align} \begin{align} J\!D\!N = (\text{day} + \left\lfloor\frac{153m+2}{5}\right\rfloor + 365y+ \left\lfloor\frac{y}{4}\right\rfloor - \left\lfloor\frac{y}{100}\right\rfloor + \left\lfloor\frac{y}{400}\right\rfloor - 32045)\text{mod}\text{7} \end{align}And I know that in Julian calendar, leap year is a year which:
\begin{align} \text{year}\:mod\:4=0 \end{align}
Using simple python program, I can solve this problem very fast. And answer (if we starting for leap year) is 28 year cycle.
But how to correctly prove this hypothesis, using only math equations? Is it possible?
If you note that $365 \equiv 1 \pmod 7$, you know that the day advances by one each non-leap year. It advances by two each leap year. Since the leap years come in a four year cycle. You need to find a cycle that is a multiple of four years that shifts the day by a multiple of seven days. You can then observe that in $28$ years, you have $7$ leap years and shift the day by $35$ days, which is a multiple of $7$. You therefore get a repeat after $28$ years.