Post Reply 
(33s) OEIS A2516: EARLIEST SEQUENCE WITH A(A(N)) = 2N
07-31-2022, 06:25 PM (This post was last modified: 07-31-2022 06:26 PM by John Keith.)
Post: #5
RE: (33s): OEIS A2516 EARLIEST SEQUENCE WITH A(A(N)) = 2N
(07-31-2022 03:32 PM)Gerald H Wrote:  ... the expression may have some meaning on 49G, as 77. and 77 are different entities on that calculator.

Speaking of which, here is a program for any RPL calculator which returns a list of A002516. Given an integer n on the stack, the length of the list will be n + (1 if n is odd else 2).

Approximate mode should be used on the 49 and 50 because MOD is slow for exact integers.

Code:

\<< \-> n
  \<< 0 3 2 n                            @ Start with a(2)
    FOR k k 2 / PICK 2 *                 @ a(2n) = 2*a(n)
      k DUP 3 + SWAP DUP
      5 - SWAP 2 / 2 MOD * + 2           @ Compute a(2n+1)
    STEP n DUP 2 + SWAP 2 MOD - \->LIST  @ Adjust for n MOD 2
  \>>
\>>

The program is based on the third formula on the OEIS page. A list of 1000 terms takes about 4.5 seconds on my 50g in approximate mode.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (33s): OEIS A2516 EARLIEST SEQUENCE WITH A(A(N)) = 2N - John Keith - 07-31-2022 06:25 PM



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