-
Notifications
You must be signed in to change notification settings - Fork 107
/
fib.cbl
35 lines (35 loc) · 1.05 KB
/
fib.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
000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. fibmain.
000030 ENVIRONMENT DIVISION.
000040 DATA DIVISION.
000050 WORKING-STORAGE SECTION.
000060 77 n USAGE IS BINARY-LONG.
000070 PROCEDURE DIVISION.
000080 MOVE 47 TO n
000090 CALL "fib" USING BY VALUE n RETURNING n.
000100 DISPLAY n
000110 STOP RUN.
000120 END PROGRAM fibmain.
000130
000140 IDENTIFICATION DIVISION.
000150 PROGRAM-ID. fib IS RECURSIVE.
000160 ENVIRONMENT DIVISION.
000170 DATA DIVISION.
000180 LOCAL-STORAGE SECTION.
000190 77 fib1 USAGE IS BINARY-LONG.
000200 77 fib2 USAGE IS BINARY-LONG.
000210 LINKAGE SECTION.
000220 77 n USAGE IS BINARY-LONG.
000230 PROCEDURE DIVISION USING BY VALUE n.
000240 IF n LESS THAN OR EQUAL TO 1
000250 MOVE n TO RETURN-CODE
000260 GOBACK
000270 END-IF
000280
000290 SUBTRACT 1 FROM n
000300 CALL "fib" USING BY VALUE n RETURNING fib1
000310 SUBTRACT 1 FROM n
000320 CALL "fib" USING BY VALUE n RETURNING fib2
000330 COMPUTE RETURN-CODE = fib1 + fib2
000340 GOBACK.
000350 END PROGRAM fib.