Notes on the computation of A056697 Don Reble, Dec 31 2012 For example let's do a(9). (This is not the fastest way to do a(9); the method is best for large N.) We want the third number which is (0, 1, or 8) modulo 9, and (0, 1, or 7) modulo 8, etc. Just compute all such numbers! (modulo lcm(9,8,...,1)) Here's the Chinese-Remainder-Theorem outer product for 8 and 9. 0 1 8 mod 9 --------------- 0 | 0 64 8 1 | 9 1 17 7 | 63 55 71 mod 8 | mod 72 Another outer product with (0, 1, 6) mod 7 gives a 27-element set. The sets grow exponentially, but not always. When doing the mod-6 numbers, one finds that 6 divides lcm(9,8,7): the set therefore can't grow, and actually shrinks. In particular, moduli 6,8,9 yield the set {0, 1, 9, 17, 71}: smaller than the 8,9 set. Such shrinkage happens often. My bit-twiddler has enough memory for the 52-to-102 set. (You needn't do mod-k if you've already done mod-2k.) It has 5845851 (3^12 x 11) elements (modulo 7041757898200960193617914702466542659236800). Yes, that's surprisingly small. So the problem is easier than it looks. Thereafter, my program must construct two such sets; it iterates through one and checks the values against the other. But then the search time increases with N, and at the prime 157, it takes too long.