On the distribution of prime ideals