source: liacs/coco/tests/code-generation/fibo.p0@ 371

Last change on this file since 371 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 681 bytes
Line 
1program fibonee;
2
3var
4 hlp: integer;
5
6function fibo(i: integer): integer;
7
8begin
9 writeinteger(i);
10 if (i <= 1) then
11 fibo := 1
12 else
13 fibo := fibo(i-1) + fibo(i-2)
14end;
15
16function plus(i: integer): integer;
17
18begin
19 plus := i + 1
20end;
21
22function geennaam(i: integer): integer;
23
24begin
25 if (i > 0) then
26 geennaam := 1 + geennaam(i-1)
27 else
28 geennaam := 0
29end;
30
31function dubbeltest(i: integer): integer;
32
33begin
34 if (i = 0) then
35 dubbeltest := 23
36 else
37 dubbeltest := dubbeltest(0) + dubbeltest(0)
38end;
39
40
41begin
42 hlp := fibo(4);
43 writereal(3.5);
44 writeinteger(hlp);
45 writeinteger(plus(4));
46 writeinteger(geennaam(6));
47 writeinteger(dubbeltest(666))
48end.
Note: See TracBrowser for help on using the repository browser.