HP Forums
(49G) OEIS A035327 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (49G) OEIS A035327 (/thread-14280.html)



(49G) OEIS A035327 - Gerald H - 12-31-2019 05:50 PM

Edit 2022-12-11: Programme slightly improved

For integer input N > -1 the programme returns the Nth element in the sequence

https://oeis.org/A035327

Not a masterpiece but does use ←A.

Code:
«
  « DUP 2 <
    IF
    THEN 1 
    ELSE 2 IDIV2
SWAP ←A EVAL 2 * 1
+
    END SWAP -
  » → ←A
  « ←A EVAL
  »
»

Improvements welcome.


RE: (49G) OEIS A035327 - John Keith - 12-31-2019 09:11 PM

Hi Gerald

Nice to see you posting sequences again. Thanks especially for posting a program using compiled local variables, which still make my head spin. Studying your program may help. Smile

While I certainly can't improve on your program, I do have one from a completely different angle, based on the structure of the sequence. Given an integer n, this program returns a list of the first 2^(n+1) terms. So for example, given the number 5 the program will return the first 64 terms.

This program also uses the ListExt command LSEQR.

Code:

\<< 1 { 1 0 } ROT 1 SWAP
  START SWAP 2 * SWAP OVER 1 - 0 LSEQR +
  NEXT NIP
\>>