The Lord has revealed to us in the Doctrine and Covenants, "Verily, this is fasting and prayer, or in other words, rejoicing and prayer."
The following story told in a Fort Collins ward sacrament meeting illustrates how this can be possible, as written by Larry Hiller:
"I had been told I was old enough to fast, so I suffered through it, one Sunday a month. Rewarding? About like a forced run in gym class. It’s painful and unpleasant, and when you get through, all you have is the satisfaction that you toughed it out.
[I continued to suffer through each fast] until one Sunday. I decided that I would really see if I could get something out of fasting besides killer breath. Why go through the discomfort and come away with nothing more than relief that it’s over? When I went off to my room, it was not to sulk, but to pray—for patience, for understanding, for an increase of testimony.
Then the hunger pangs faded into the background, partly because I was tuning them out, and partly because my body seemed to shift into another gear. As the day progressed, I actually became happy. In fast and testimony meeting I found myself watching the speakers and listening to their testimonies, rather than watching the clock and listening to my stomach. Being there felt good.
When dinner time finally arrived, I discovered that I was able to sit calmly. A new sense of self-control allowed me to eat reasonably, instead of giving way to the usual gluttony of the “feast of the fast over.”
It’s easy to go through the motions and discomfort of fasting without finding joy in it. There are rewards that go far beyond the meager satisfaction of just having endured."