I'd also say that programming is a mathematical endeavor by nature; logical manipulation is a branch of mathematics. If you're working at a level of abstraction where you aren't specifying logical manipulations, then you're filling out a template, not what I'd call "programming".
I learned basic trigonometry early (with a textbook and some advice from a school mathematics teacher) for the purpose of rotating vector graphics in BASIC to make a Spacewar clone. I expect there are many people who learned about complex numbers because they wanted to draw fractals. And linear algebra can sound boring until you realize how useful transformation matrices are in graphics programming. Programming is a great motivation for learning mathematics because it's so much more fun when you have mathematics skills.