-
Notifications
You must be signed in to change notification settings - Fork 11
/
fizzbuzz.a60
55 lines (50 loc) · 1.69 KB
/
fizzbuzz.a60
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
begin
comment Language: Algol 60;
comment Web site: https://www.algol60.org/;
comment https://www.algol60.org/translators/a60-0.22.tar.gz;
comment Last tested on: Ubuntu 22.04.5;
comment Requires: Build and install a60 interpreter from source;
integer procedure idivide(x, y); integer x, y;
comment ÷ is integer division, but the a60 interpreter doesn't recognize it;
begin
integer result;
result := entier(x / y);
idivide := result;
end;
integer procedure mod(x, y); integer x, y;
begin
mod := x - idivide(x, y) * y;
end;
procedure printdigit(d); integer d;
comment Ugh! ;
begin
if d = 0 then outstring(1, "0")
else if d = 1 then outstring(1, "1")
else if d = 2 then outstring(1, "2")
else if d = 3 then outstring(1, "3")
else if d = 4 then outstring(1, "4")
else if d = 5 then outstring(1, "5")
else if d = 6 then outstring(1, "6")
else if d = 7 then outstring(1, "7")
else if d = 8 then outstring(1, "8")
else if d = 9 then outstring(1, "9")
end;
procedure printinteger(n); integer n;
comment outinteger() prints leading and trailing spaces;
begin
if n >= 10 then printdigit(idivide(n, 10));
printdigit(mod(n, 10));
end;
integer i;
for i := 1 step 1 until 100 do
begin
if mod(i, 15) = 0 then outstring(1, "FizzBuzz\n")
else if mod(i, 3) = 0 then outstring(1, "Fizz\n")
else if mod(i, 5) = 0 then outstring(1, "Buzz\n")
else
begin
printinteger(i);
outstring(1, "\n");
end;
end;
end