Test for prime using the Fermats theorem