Don't use '=' for comparison, always use '=='. (In this case you don't need to, because you're doing a loop)
I think the problem is the loop on the third line, while (%a = %b) {
Change it to while (%a <= %b) { and that I think would solve the problem.