added way for loop to discontiue if 'N' is smaller than the prime list