Answer:
2
Explanation:
3142 is even, so you only need to test divisibility by 2.
_____
Additional comment
For numbers in the neighborhood of 3142, you would usually consider testing primes up to the square root. That root is about 56, so the largest prime you'd use for testing would be 53.
In general, primes will end in odd numbers other than 5, so the numbers in the neighborhood that might be prime are 3143, 3149. (3141 has a sum of digits of 9, so you know it is divisible by 9. 3147 is 6 more, so is divisible by 3.)
The nearest primes are actually 3137 and 3163.