HP Forums

Full Version: (35S) Ulam Spiral Programme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
Reference URL's