-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproblem32.cbl
executable file
·60 lines (58 loc) · 1.44 KB
/
problem32.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
IDENTIFICATION DIVISION.
PROGRAM-ID. Problem32.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Accum PIC 99999.
01 Counter PIC 99999.
01 Upper PIC 99999.
01 Candidate PIC 99999.
01 Candidate0 PIC 99999.
01 Str0 PIC X(6).
01 Str1 PIC X(6).
01 Str2 PIC X(6).
01 StrC PIC X(20).
01 Temp PIC 9.
01 TempS PIC X(1).
01 Tally PIC 99.
01 Okay PIC 9.
PROCEDURE DIVISION.
COMPUTE Accum = 0.
PERFORM VARYING Counter FROM 1 BY 1 UNTIL 9999 < Counter
COMPUTE Upper = Counter / 2
PERFORM VARYING Candidate FROM 1 BY 1
UNTIL Candidate > Upper
IF FUNCTION Mod(Counter, Candidate) = 0
MOVE Counter TO Candidate0
DIVIDE Candidate INTO Candidate0
MOVE Candidate TO Str0
MOVE Candidate0 TO Str1
MOVE Counter TO Str2
STRING
Str0 DELIMITED BY SIZE
Str1 DELIMITED BY SIZE
Str2 DELIMITED BY SIZE
INTO StrC
MOVE 1 TO Okay
PERFORM VARYING Temp FROM 1 BY 1 UNTIL 8 < Temp
MOVE Temp TO TempS
MOVE 0 TO Tally
INSPECT StrC TALLYING Tally FOR ALL TempS
IF Tally NOT = 1
MOVE 0 TO Okay
END-IF
END-PERFORM
MOVE Temp TO TempS
MOVE 0 TO Tally
INSPECT StrC TALLYING Tally FOR ALL TempS
IF Tally NOT = 1
MOVE 0 TO Okay
END-IF
IF Okay = 1
ADD Counter TO Accum
EXIT PERFORM
END-IF
END-IF
END-PERFORM
END-PERFORM.
DISPLAY Accum.
STOP RUN.