Post Reply 
(33s) OEIS A4444: Nimsum N+3
08-18-2022, 08:28 AM (This post was last modified: 08-18-2022 12:19 PM by Gerald H.)
Post: #1
(33s) OEIS A4444: Nimsum N+3
Takes a natural number from the stack & returns A4444(N) to stack.

https://oeis.org/A004444

Nth in natural order for run of four integers in natural order reversed, then next four integers in natural order reversed ….
Preserves stack.

Code:
1.    LBL B
2.    STO N
3.    CLx
4.    N+(-1)^N+2*(-1)^IDIV(N:2)
5.    RTN

B: LN = 40        CK = 25E5
Find all posts by this user
Quote this message in a reply
08-18-2022, 11:55 AM (This post was last modified: 08-18-2022 05:46 PM by Didier Lachieze.)
Post: #2
RE: (33s) OEIS A4444: Nimsum N+3
Another way to do it:

Code:
1.    LBL B
2.    STO N
3.    CLx
4.    4xIDIV(N:4)+RMDR(3-N:4)
5.    RTN

Note: I don’t have a 33s, just a 35s, so I’m not providing CK or LN.

EDIT: adding a shorter solution.

Code:
1.    LBL B
2.    STO N
3.    CLx
4.    N-3+2*RMDR(3-N:4)
5.    RTN
Find all posts by this user
Quote this message in a reply
Post Reply 




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