Ulam spiral – non-trivial neighbors of a generic element (HP-12C)
|
01-25-2018, 05:17 PM
(This post was last modified: 01-25-2018 11:37 PM by Gerson W. Barbosa.)
Post: #1
|
|||
|
|||
Ulam spiral – non-trivial neighbors of a generic element (HP-12C)
Ulam spiral
64 63 62 61 60 59 58 57 37 36 35 34 33 32 31 56 38 17 16 15 14 13 30 55 39 18 05 04 03 12 29 54 40 19 06 01 02 11 28 53 41 20 07 08 09 10 27 52 42 21 22 23 24 25 26 51 43 44 45 46 47 48 49 50 Code:
Examples: 22 R/S -> 45 x<>y -> 7 31 R/S -> 56 x<>y -> 58 n1 = 5 + n + 2*INT(√(4*n - 2)) (This formula from Don Shepherd’s recent article on the same subject). For elements on the main diagonals, where either (n - 1) or (4*n - 3) are perfect squares, n2 = n1 - 2 Otherwise n2 = 2*n + 8 - n1 The central element, 1, has three non-trivial neighbors: 4, 6 and 8. The program will return 6 and 8. Code-optimization is left as an exercise. Edited to fix a typo in step 04. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Ulam spiral – non-trivial neighbors of a generic element (HP-12C) - Gerson W. Barbosa - 01-25-2018 05:17 PM
RE: Ulam spiral – non-trivial neighbors of a generic element (HP-12C) - Don Shepherd - 01-25-2018, 05:27 PM
RE: Ulam spiral – non-trivial neighbors of a generic element (HP-12C) - Gerson W. Barbosa - 01-27-2018, 03:26 AM
RE: Ulam spiral – non-trivial neighbors of a generic element (HP-12C) - Don Shepherd - 01-27-2018, 08:06 AM
RE: Ulam spiral – non-trivial neighbors of a generic element (HP-12C) - Don Shepherd - 01-26-2018, 05:25 AM
|
User(s) browsing this thread: 1 Guest(s)