Could you elaborate on the mental math part - do you do particular exercises?
It gives your working memory and symbol manipulation a workout. Coding uses these facilities, but might not work them directly enough to be as good at training them. That's my theory so far.