Rabin Miller implementation