Post Reply 
OEIS featured in The New York Times
07-24-2024, 09:08 AM (This post was last modified: 07-24-2024 09:21 AM by Gil.)
Post: #12
RE: OEIS featured in The New York Times
Just a possible, simple adaptation for the HP50G calculator:

Code:
\<< DUP 1 1 \-> n l p
  \<< 1 SWAP 1 \=/
    IF
    THEN 1 n 1 -
      START l 2 MOD NOT
        IF
        THEN l 2 /
        ELSE l p NEXTPRIME DUP 'p' STO +
        END DUP 'l' STO
      NEXT
    END n \->LIST
  \>>
\>>

As argument,
enter the number n
for the the number of elements to be calculated.

But in fact, no necessity to save the last element calculated, we can just play on its duplication. The above program becomes then:
Code:
\<< DUP 1 \-> n p
  \<< 1 SWAP 1 \=/
    IF
    THEN 1 n 1 -
      START DUP DUP 2 MOD NOT
        IF
        THEN 2 /
        ELSE p NEXTPRIME DUP 'p' STO +
        END
      NEXT
    END n \->LIST
  \>>
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: OEIS featured in The New York Times - Gil - 07-24-2024 09:08 AM



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