I'll go update the code now, but you're right; there needs to be a check for division by 2.
In reply to Re^3: ulam's spiral too slow by liverpole in thread ulam's spiral too slow by orange