This is similar to my C program except overflow at (2**31) is disabled, and a limit of 320 iterations