-
Notifications
You must be signed in to change notification settings - Fork 0
/
026.cbl
33 lines (28 loc) · 978 Bytes
/
026.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
32
33
IDENTIFICATION DIVISION.
PROGRAM-ID. Euler026.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 a PIC 9(4) COMP.
01 d PIC 9(4) COMP.
01 l PIC 9(4) COMP.
01 max PIC 9(4) COMP.
01 maxl PIC 9(4) COMP VALUE 0.
01 out PIC Z(10).
PROCEDURE DIVISION.
PERFORM VARYING d FROM 3 BY 2 UNTIL d > 1000
IF FUNCTION MOD (d, 5) > 0
MOVE FUNCTION MOD (10, d) TO a
MOVE 1 to l
PERFORM UNTIL a <= 1
ADD 1 to l
MOVE FUNCTION MOD(a * 10, d) TO a
END-PERFORM
IF l > maxl
MOVE l TO maxl
MOVE d TO max
END-IF
END-IF
END-PERFORM
MOVE max TO out
DISPLAY FUNCTION TRIM (out)
STOP RUN.