Checking left and right subsequences to be prime