HP Forums
(33s) Ulam Spiral - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (33s) Ulam Spiral (/thread-18730.html)



(33s) Ulam Spiral - Gerald H - 08-29-2022 09:36 AM

The Ulam Spiral

https://en.wikipedia.org/wiki/Ulam_spiral

programme returns the indexes of the two difficult neighbouring boxes to the box index provided as integer input.

The programme preserves the stack.

Code:
1.    LBL U
2.    STO N
3.    4
4.    *
5.    2
6.    –
7.    ENTER
8.    SQRT
9.    IP
10.    STO K
11.    CLx
12.    4
13.    –
14.    SQRT
15.    IP
16.    K-0.37612771
17.    –
18.    SGN
19.    STO* K
20.    CLx
21.    N-2*K+3
22.    N+ABS(2*K)+5
23.    RTN

U: LN = 136    CK = A6C4