Why do characters recite π (pi) to distract themselves? I know that some characters recite pi digits to either calm themselves, or to distract themselves. I remember a particular case in the series r-15.

Is there any particular reason it is pi?
This seems to be a play on the psychological trick of "counting to 10".
Counting to 10 (or more) is a methodology often used to help people with anxiety, fear, anger and in the case or R-15, arousal. 

By counting to ten, you actively keep your mind busy, effectively distracting you from whatever is causing your anxiety, fear etc.

In R-15 instead of counting to 10 however, Ritsu Enshū (円周 率 Enshū Ritsu) recites π. As he is regarded as a genius mathematician, it makes more sense that reciting π would be more mentally challenging for him, then counting to 10 would be. And thus be a more effective way of distracting him from his arousal. 

According to the wiki page, it is also a clever play on his name, as this supposedly means π.