Help with prime number and modulo

Hi,

I have a question about performing a modulo with large prime numbers.

If I want to check if A^X + B^Y = C^Z, I was told to try the following filtering method:

(A^XmodN + B^YmodN)modN = C^ZmodN with two large values of N that are prime.

I dont understand the significance of the values of N being prime. Apparently this causes it to be a better filter than with values of N that are not prime.

Why is that? I only have very basic Math knowledge so please try and help me out.