Note that with the document.write, many browser versions
hold the result in memory and write at the end. This is happening
here. The example with the alert shows going through the loop step
by step as the alert shows the result of each pass.
The end of the math facts