Program to print numbers format using cobol

IDENTIFICATION DIVISION.

PROGRAM-ID.

ENVIRONMENT DIVISION.

DATA DIVISION.

WORKING-STORAGE SECTION.

77 N PIC 9(2).

77 I PIC 9(2).

77 R PIC 9(2).

77 J PIC 9(2).

77 K PIC 9(2).

77 S PIC 9(2) VALUE 1.

77 P PIC Z(2).

PROCEDURE DIVISION.

MAIN-PARA.

DISPLAY " ENTER N VALUE ".

ACCEPT N.

DISPLAY (1 , 1) ERASE.

MOVE 1 TO COL.

PERFORM X-PARA VARYING I FROM 1 BY 1 UNTIL I > N.

STOP RUN.

X-PARA.

COMPUTE R = 40 - 3 * I.

MOVE I TO LIN.

PERFORM B-PARA R TIMES.

MOVE R TO COL.

PERFORM Y-PARA VARYING J FROM 1 BY 1 UNTIL J > I.

B-PARA.

COMPUTE COL = COL + 1.

Y-PARA.

IF (J = 0 OR I = 0)

MOVE 1 TO S

ELSE

COMPUTE S = S * (I - J + 1) / J

MOVE S TO P

DISPLAY (LIN , COL) P.

COMPUTE COL = COL + 1.