If there’s a spot open for playtesting I’m interested, I’d like to see it live ! ]]>

Looking forward to seeing it in action ! ]]>

Anyways, this was a good example of optimization. (I also enjoyed the Pimp My Ride parody !).

However, for increasingly larger amounts of larger primes (see RSA : http://en.wikipedia.org/wiki/RSA_(algorithm)), a different approach is required.

One way to go about it is probabilistic algorithms; in this case, you would generate a random large odd number and then check if it’s a prime.

There are a number of tests available do to so; I have implemented the Miller-Rabin primality test in Java but don’t have the code available (make use of BigIntegers !).

Each test has a high probability of truthfulness : in Miller-Rabin’s case, it returns a false positive 1/4 of the time. To strengthen the result, the test can be run multiple times and the probability of a false positive would decrease by a factor of 1/4 each time.

Other tests include Fermat’s test and the Solovay-Strassen test (see http://en.wikipedia.org/wiki/Primality_test).

Note that there are special numbers called Carmichael numbers (see http://en.wikipedia.org/wiki/Carmichael_number) which the tests do not pick up on.

However, they are extremely rare and on average it is unlikely to cause problems (unless you’re in a mission critical project and you’re relying on prime numbers for some reason).