HP Forums

Full Version: (49G) Gould's Sequence OEIS A001316
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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#
  ;
;
Reference URL's