For prime numbers, it is enough to verify that the number itself is congruent to 1 mod 9. The first composite term is 361, which is the square of the first prime in this sequence. - Alonso del Arte, May 02 2012