HP Forums
(35S) Ulam Spiral Programme - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (35S) Ulam Spiral Programme (/thread-2561.html)



(35S) Ulam Spiral Programme - Gerald H - 12-05-2014 08:13 AM

For integer entry N > 1 the programme returns the two difficult non-diagonal neighbours of N

1 LBL U
2 STO N
3 4
4 *
5 2
6 -
7 IP(SQRT(REGX))
8 2*REGX
9 STO K
10 R↓
11 x<>y
12 4
13 -
14 SQRTx
15 IP
16 x<y?
17 -K►K
18 N-K+3
19 N+ABS(K)+5
20 RTN

The spiral begins

10 ....
09 2 3
08 1 4
07 6 5

So for entry 2 the programme returns 9 & 11.