It's not clear what j is. I think there are probably better variable names for a, b, n and j. i is OK :)