Abu Qatada reported that a person came to the Messenger of Allah (ﷺ) and said
How do you fast? The Messenger of Allah (ﷺ) felt annoyed. When 'Umar (Allah be pleased with him) noticed his annoyance, he said: We are well pleased with Allah as our Lord, with Islam as our code of life, and with Muhammad as our Prophet. We seek refuge with Allah from the anger of Allah and that of His Messenger. 'Umar kept on repeating these words till his (the Prophet's) anger calmed down. Then Umar said: Messenger of Allah, what is the position of one who fasts perpetually? He (ﷺ) said: He neither fasted nor broke it, or he said: He did not fast and he did not break it. 'Umar said: What about him who fasts for two days and does not fast one day? He (ﷺ) said: Is anyone capable of doing that? He ('Umar) said: What is the position of him who fasts for a day and doesn't fast on the other day? Thereupon he (the Holy Prophet) said: That is the fast of David (peace be upon him). He ('Umar) said: What about him who fasts one day and doesn't fast for two days. Thereupon he (the Messenger of Allah) said: I wish I were given the strength to do that. Thereafter he (ﷺ) said: Fasting three days every month and that of Ramadan every year is a perpetual fasting. I seek from Allah that fasting on the day of 'Arafa may atone for the sins of the preceding and the coming years, and I seek from Allah that fasting on the day of Ashura may atone for the sins of the preceding year.