Implementation of Ulam spiral