first working version of prime check, terrible performance