Task

Print out the first   15   Catalan numbers by extracting them from Pascal's triangle.



See

   Catalan Numbers and the Pascal Triangle.     This method enables calculation of Catalan Numbers using only addition and subtraction.
   Catalan's Triangle for a Number Triangle that generates Catalan Numbers using only addition.
   Sequence A000108 on OEIS has a lot of information on Catalan Numbers.
Related Tasks

Pascal's triangle

CATALAN  CSECT                         
         USING  CATALAN,R13,R12
SAVEAREA B      STM-SAVEAREA(R15)
         DC     17F'0'
         DC     CL8'CATALAN'
STM      STM    R14,R12,12(R13)
         ST     R13,4(R15)
         ST     R15,8(R13)
         LR     R13,R15
         LA     R12,4095(R13)
         LA     R12,1(R12)
*        ----   CODE
         LA     R0,1
         ST     R0,T            t(1)=1
         LA     R4,0            ix:i=1
         LA     R6,1            by 1
         LH     R7,N            to n 
LOOPI    BXH    R4,R6,ENDLOOPI  loop i
         LR     R5,R4           ix:j=i+1
         LA     R5,2(R5)        i+2
         LA     R8,0
         BCTR   R8,0            by -1 
         LA     R9,1            to 2
LOOP1J   BXLE   R5,R8,ENLOOP1J  loop j
         LR     R10,R5          j
         BCTR   R10,0
         SLA    R10,2
         L      R2,T(R10)       r2=t(j)  
         LR     R1,R10          j
         SH     R1,=H'4'
         L      R3,T(R1)        r3=t(j-1)
         AR     R2,R3           r2=r2+r3 
         ST     R2,T(R10)       t(j)=t(j)+t(j-1)
         B      LOOP1J
ENLOOP1J EQU    *
         LR     R1,R4           i
         BCTR   R1,0
         SLA    R1,2
         L      R3,T(R1)        t(i)
         LA     R1,4(R1)
         ST     R3,T(R1)        t(i+1)
         LR     R5,R4           ix:j=i+2
         LA     R5,3(R5)        i+3
         LA     R8,0
         BCTR   R8,0            by -1 
         LA     R9,1            to 2
LOOP2J   BXLE   R5,R8,ENLOOP2J  loop j
         LR     R10,R5          j
         BCTR   R10,0
         SLA    R10,2
         L      R2,T(R10)       r2=t(j)  
         LR     R1,R10          j
         SH     R1,=H'4'
         L      R3,T(R1)        r3=t(j-1)
         AR     R2,R3           r2=r2+r3 
         ST     R2,T(R10)       t(j)=t(j)+t(j-1)
         B      LOOP2J
ENLOOP2J EQU    *
         LR     R1,R4           i
         BCTR   R1,0
         SLA    R1,2
         L      R2,T(R1)        t(i)
         LA     R1,4(R1)
         L      R3,T(R1)        t(i+1)
         SR     R3,R2
         CVD    R3,P            
         UNPK   Z,P
         MVC    C,Z
         OI     C+L'C-1,X'F0'
         MVC    WTOBUF(8),C+8
         WTO    MF=(E,WTOMSG)		  
         B      LOOPI
ENDLOOPI EQU    *
*        ----   END CODE
         CNOP   0,4
         L      R13,4(0,R13)
         LM     R14,R12,12(R13)
         XR     R15,R15
         BR     R14
*        ----   DATA
N        DC     H'15'
T        DC     17F'0'
P        DS     PL8
Z        DS     ZL16
C        DS     CL16
WTOMSG   DS     0F
         DC     H'80'
         DC     H'0'
WTOBUF   DC     CL80' '
         YREGS  
         END