David went up at the saying of Gad, which he spoke in the name of Yahweh.
David’s response to Gad’s instructions indicated his true repentance. He left the decision about punishment entirely in God’s hands and did not seek to control it.