BTW: Thanks for looking at my code, Scott. Unfortunately, that didn't work either. The problem is in the math code, not the looping code. The program seems to calculate the first 3 digits correctly, then screws up.