Formula for occurrence of leap years in the Jewish calendar Over at Judaism.SE, there was a discussion about a formula to determine leap years in the Jewish calendar. Basically, the calendar follows a 19-year cycle, and seven of those years -- 3, 6, 8, 11, 14, 17, and 19 -- are leap years. Someone reduced this to the simple equation: (7y+1) mod 19 < 7.
My question is whether there is any rhyme or reason as to why this works, and is there a method to go about determining such formulas -- or is it all simply trial and error?
 A: There is a way to motivate such formulas but not completely get rid of trial and error. For the following I am indebted to "Calendrical Calculation" by Dershowitz and Reingold. 
It turns out that the leap year structure of several other calendars, among them the Islamic, also has can be characterized by conditions of the form $(by + c) \bmod l < b$. It turns out that this can be explained if one assumes they have adopted a common method for distributing the leap years as evenly as possible.   
Assume we want to have $l$ leap-years among the years $1,2,\ldots n$. (Where $n \geq l$.) One way of accomplishing this is to say that year $y$ is a leap-year if and only if there exists an integer $k$ such that $y-1 < k \frac{n}{l} \leq y$. We can imagine marking out the multiples of $\frac{n}{l}$ on the number line and then our condition means that $y$ is the first integer after one of these multiples. 
We can rewrite the condition we impose as $k\frac{n}{l} \leq y < k\frac{n}{l}+1$ which in turn is equivalent to 
$$ kn \leq yl < kn +l.$$
This is true for some integer $k$ if and only if $ (yl \bmod n) < l$. 
Now you might object that this does not give the right answer and you would of course be correct. However this can be remedied. There is nothing that forces us to start the cycle at year $1$ of the calendar. If we instead start the cycle at year $a$ our formula becomes 
$$ ((y-a+1)l \bmod n) < l.$$
Setting $l= 7, $n=19 and $a=9$ we reproduce the right formula after simplification. (The trial and error part is now really only in finding $a$.) 
A: It follows the steps in an octave of music.  Full step, full step, half step, full step, full step, full step, half step.  The full steps the third year is leap year.  The half steps the second year is leap year.  Thus the leap years are in a 19 year cycle are as follows: 3, 6, 8, 11, 14, 17, 19.  No trial and error, just know the scale.
