HP Forums
(33s) OEIS A4444: Nimsum N+3 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (33s) OEIS A4444: Nimsum N+3 (/thread-18683.html)



(33s) OEIS A4444: Nimsum N+3 - Gerald H - 08-18-2022 08:28 AM

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



RE: (33s) OEIS A4444: Nimsum N+3 - Didier Lachieze - 08-18-2022 11:55 AM

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