Post Reply 
Ulam spiral – non-trivial neighbors of a generic element (HP-12C)
01-27-2018, 03:26 AM (This post was last modified: 01-27-2018 04:09 AM by Gerson W. Barbosa.)
Post: #4
RE: Ulam spiral – non-trivial neighbors of a generic element (HP-12C)
(01-25-2018 05:27 PM)Don Shepherd Wrote:  Yes, I knew my programs get a sqrt(neg number) error for n=1.

Don, I did notice that error, but it was not my intention to fix it. I was just interested in knowing the formulas you have used. After analyzing the first few lines of your 12C program and getting the formula for the first non-trivial neighbor I got lazy and rather than trying to figure out the formula for the second one I decided to find a relationship between them. That was not hard, but probably a straightforward conversion of your program to RPL would have yielded better byte counts. Each of the following is 117.5 bytes long:


« DUP 5 + OVER 4 * 2 - √ IP DUP + + SWAP DUP 4 * 3 - √ FP OVER 1 - √ FP * NOT { DROP DUP 2 - } { 4 + DUP + OVER - } IFTE
»

« DUP 5 + OVER 4 * 2 - √ IP DUP + + 2 OVER - ROT DUP 4 * 3 - √ FP OVER 1 - √ FP * NOT { DROP NEG } { 3 + DUP + + } IFTE
»

« DUP 5 + OVER 4 * 2 - √ IP DUP + + DUP 2 - ROT DUP 4 * 3 - √ FP OVER 1 - √ FP * NOT { DROP } { 3 + DUP + SWAP - } IFTE
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Ulam spiral – non-trivial neighbors of a generic element (HP-12C) - Gerson W. Barbosa - 01-27-2018 03:26 AM



User(s) browsing this thread: 1 Guest(s)