I've seen many times that math problems aren't the best choice for contexts when learning how to program. This seems to be especially true for women. As discussed in one publication (Interventions and Solutions in Gender and IT):
Research has also shown that another factor affecting the retention of IT students is the type of assignments given in CS classes. For example, female students prefer to work on real-world applications, while males prefer to work on game problems. Yet, current textbooks continue to provide a large percentage of math problems.But could math problems for programming work when you get a compelling context that leaves you with a burning question? Something that is most easily answered using code? Or should this approach be confined to math classes and not be used to teach programming?