-
Notifications
You must be signed in to change notification settings - Fork 0
/
009.cbl
31 lines (26 loc) · 933 Bytes
/
009.cbl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
IDENTIFICATION DIVISION.
PROGRAM-ID. Euler009.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 r PIC 9(3) COMP VALUE 0.
01 rs2 PIC 9(6) COMP.
01 s PIC 9(3) COMP.
01 t PIC 9(3) COMP.
01 rem PIC 9(3) COMP.
01 prd PIC 9(10) COMP.
01 out PIC Z(10).
PROCEDURE DIVISION.
PERFORM FOREVER
ADD 2 TO r
COMPUTE rs2 = r * r / 2
PERFORM VARYING s FROM 1 BY 1 UNTIL s * s > rs2
DIVIDE rs2 BY s GIVING t REMAINDER rem
IF rem = 0 AND 3 * r + 2 * s + 2 * t = 1000
GO TO DONE
END-PERFORM
END-PERFORM.
DONE.
COMPUTE prd = (r + s) * (r + t) * (r + s + t)
MOVE prd TO out
DISPLAY FUNCTION TRIM (out)
STOP RUN.