On 17.06.2009, at 13:57, Ftf 3k3 wrote:

> I tried to follow the instructions here:
> http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html
> ---------------8<-------------
>        if (a ** d) % n == 1 or (a ** ((2 ** r) * d)) % n == -1


According to the page you posted your condition is not correct.
I don't read it carefully nor I tested it but it's obvious that
you forget to calculate the -1 mod n
  .. == (-1 % n)

Hth. regards, Sandor Szs
--