How often in years do calendars repeat with the same day-date combinations (Julian calendar)? 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?

I can directly say 28 years. It's because 7 is a prime number, thus is relatively prime with every natural number smaller than itself. How does this information helps us solve the problem. This way:
You know that $365 \equiv 1 (mod\, 7)$ and $366 \equiv 2 (mod\, 7)$. As 1 year in each $4$ year contains $366$ days. Then, in every $4$ years, we have a $5$ day iteration in days. So when does the loop goes back to the beginning? We have to find the Leas Common Multiple of $5$ and $7$, to find the number of the days iterated. $lcd[5,7]=35$. That is, when the loop was over, we were back to the beginning. In how many years, $35$ days iteration happens? $35*4/5=28$ years. 
Edit: I've noticed that I did not mention how to use the info at the beginning. As 7 is relatively prime with every number smaller than itself, the answer would always* be the multiplication of 7 with loop lenght of years for different day content (Sorry for my English, that was a complicated way to explain. $4$ for this situation, as in every 4 years we have $1$ plus day. That is, in any 2 years that have 4k years difference, they have the same number of days). 
Anyway, in any case we're gonna look for we're gonna look at the lenght of the year loop (let's say $l$ years) and days of iteration (let's say $i$ days). Then find the $lcm[7,i]$ then multiplicate it with $l/i$. As $7$ is prime, if $i<7, lcm[7,i]=7*i$. Then what we're looking for is actually $7*i*l/i = 7*l$
*Except $6$ years of loop. If it was $6$, then we would be looking for $lcm[7,7]$ which is $7$.
