This is effectively an optimized implementation of [this algorithm](https://web.archive.org/web/20150307042855/http://www.mathblog.dk/project-euler-51-eight-prime-family/).
In each iteration we generate the number (from value, pattern and digit) and test for it primeness (with a simple [primality test](https://en.wikipedia.org/wiki/Primality_test) - no prime sieve).