2 Sam 24:10-17 NKJV
10 And David's heart condemned him after he had numbered the people. So David said to the Lord, "I have sinned greatly in what I have done; but now, I pray, O Lord, take away the iniquity of Your servant, for I have done very foolishly."
11 Now when David arose in the morning, the word of the Lord came to the prophet Gad, David's seer, saying, 12 "Go and tell David, 'Thus says the Lord: "I offer you three things; choose one of them for yourself, that I may do it to you."'" 13 So Gad came to David and told him; and he said to him, "Shall seven years of famine come to you in your land? Or shall you flee three months before your enemies, while they pursue you? Or shall there be three days' plague in your land? Now consider and see what answer I should take back to Him who sent me."
14 And David said to Gad, "I am in great distress. Please let us fall into the hand of the Lord, for His mercies are great; but do not let me fall into the hand of man."
15 So the Lord sent a plague upon Israel from the morning till the appointed time. From Dan to Beersheba seventy thousand men of the people died. 16 And when the angel stretched out His hand over Jerusalem to destroy it, the Lord relented from the destruction, and said to the angel who was destroying the people, "It is enough; now restrain your hand." And the angel of the Lord was by the threshing floor of Araunah the Jebusite.
17 Then David spoke to the Lord when he saw the angel who was striking the people, and said, "Surely I have sinned, and I have done wickedly; but these sheep, what have they done? Let Your hand, I pray, be against me and against my father's house."