Initial conversion to Julia; handling of +/- 2, +- 4 cases not currently implemented.