5 Then He brought him outside and said, "Look now toward heaven, and count the stars if you are able to number them." And He said to him, "So shall your descendants be."
-Genesis 15:5
26 So the LORD said, "If I find in Sodom fifty righteous within the city, then I will spare all the place for their sakes."
27 Then Abraham answered and said, "Indeed now, I who am but dust and ashes have taken it upon myself to speak to the Lord: 28 Suppose there were five less than the fifty righteous; would You destroy all of the city for lack of five?"
So He said, "If I find there forty-five, I will not destroy it."
29 And he spoke to Him yet again and said, "Suppose there should be forty found there?"
So He said, "I will not do it for the sake of forty."
30 Then he said, "Let not the Lord be angry, and I will speak: Suppose thirty should be found there?"
So He said, "I will not do it if I find thirty there." -Genesis 18:26-30
The Problem
The use of "if" by God in these two verses indicates that God is not omniscient: God should know whether or not Abraham is able to count the stars and God should know how many righteous will be found in Sodom.
The Answer
In Genesis 15, God challenges Moses. God knows that Moses cannot count the stars, which shows Moses just how greatly God will bless his descendants.
In Genesis 18, the emphasis is not on God's foreknowledge but God's mercy. The question is, for how many righteous people would God spare Sodom? Much like an auction, God had a "reserve price" that was not met. Not even ten rigtheous people lived in Sodom, however.
Bible Apologetics Index