I wrote a program which is not important now, but it was on this Fermat's theorem. Now the problem is the output was not as expected. I know the question is not too good or off the mark but I just can't solve the error which is that there is an occurrence of 4 here in the output which must not be there. I'm unable to debug it.
The theorem:  
 
for x in range(1,100):
 m=5**(x-1)
 if m%x>1:    
   pass
 else:
   print"prime",x
Output is this:

 
     
     
    