Ulam spiral – nontrivial neighbors of a generic element (HP12C)

01272018, 03:26 AM
(This post was last modified: 01272018 04:09 AM by Gerson W. Barbosa.)
Post: #4




RE: Ulam spiral – nontrivial neighbors of a generic element (HP12C)
(01252018 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 nontrivial 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 » 

« Next Oldest  Next Newest »

Messages In This Thread 
Ulam spiral – nontrivial neighbors of a generic element (HP12C)  Gerson W. Barbosa  01252018, 05:17 PM
RE: Ulam spiral – nontrivial neighbors of a generic element (HP12C)  Don Shepherd  01252018, 05:27 PM
RE: Ulam spiral – nontrivial neighbors of a generic element (HP12C)  Gerson W. Barbosa  01272018 03:26 AM
RE: Ulam spiral – nontrivial neighbors of a generic element (HP12C)  Don Shepherd  01272018, 08:06 AM
RE: Ulam spiral – nontrivial neighbors of a generic element (HP12C)  Don Shepherd  01262018, 05:25 AM

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