I'm 42. I use mental math to stay sharp. Exercise and diet also make a difference.
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.