HP Forums
(49G) Gould's Sequence OEIS A001316 - 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) Gould's Sequence OEIS A001316 (/thread-4624.html)



(49G) Gould's Sequence OEIS A001316 - Gerald H - 09-02-2015 07:43 AM

Gould's sequence

http://oeis.org/A001316

counts the number of odd terms in the rows of Pascal's triangle.

For integer input the programme returns the number of odd occurences in that line of Pascal's triangle, starting with line zero.

Code:

::
  CK1&Dispatch
  # FF
  ::
    FPTR2 ^DupQIsZero?
    casedrop
    Z1_
    ZEROSWAP
    FPTR2 ^Z>ZH
    FPTR2 ^ZBits
    ZERO_DO
    INDEX@
    FPTR2 ^ZBit?
    IT
    SWAP#1+SWAP
    LOOP
    DROP
    Z2_
    SWAP
    FPTR2 ^RP#
  ;
;