Hi,
For any odd composite 'N', let u = (N-1)/2, v = u+1, then u^2(mod p) = v^2(mod p) if and only if 'p' is a factor of 'N'. More info kadinumberprops.blogspot.in