000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. NILAKANTHA_PI.
000300 AUTHOR. AmazingMech2418.
000400 DATE-WRITTEN. 5/25/2021.
000500 REMARKS.
000510     Approximates pi using the Nilakantha Series.
000520     Calculates to 15 decimal places.
000600 DATA DIVISION.
000700 WORKING-STORAGE SECTION.
000800 01 PI PIC 9(1)V9(20) VALUE 3.
000900 01 A PIC 9(10) VALUE 2.
001000 01 S PIC S9(1) VALUE 1.
001100 01 TEMP PIC S9(1)V9(20).
001200 01 N PIC 9(10) VALUE 0.
001300 01 DISP PIC 9(1)V9(15).
001400 PROCEDURE DIVISION.
001450 PARA.
001500     PERFORM PARA1 UNTIL N = 150000.
001600     MOVE PI TO DISP
001700     DISPLAY "PI = "DISP.
001800     STOP RUN.
001850 PARA1.
001900     COMPUTE TEMP = S * (4 / (A * (A * (A + 3) + 2))).
002000     ADD TEMP TO PI.
002100     ADD 2 TO A.
002200     COMPUTE S = 0 - S.
002300     ADD 1 TO N.
