I've seen someone take a piece of code from 72 lines down to 3 lines by just doing some simple mathematical analysis before actually getting to refactoring. The code was also simpler, and easier to understand. Do you need math for be a good programmer? No. Does it help to know math while programming? Absolutely.
But I've also heard about math PhDs write the sloppiest code code imaginable: functions 1000+ lines long, copying and pasting functions to add a parameter... (in production code for a software company, not a research project).
So like you said, math helps but I'd like to extend that thought and say that you can make bigger gains elsewhere. For example, if you're a sloppy coder and don't know math, go out and get a book like "Code Complete," "The Pragmatic Programmer" or "Clean Code" first.