Update isprime function

New isprime function, using fast prime algorithm.