Diff the results of these two to see how much modulo can differ.
Cat's Eye Technologies
11 years ago
|
0 |
|
|
1 |
for i = -5,5,1 do
|
|
2 |
for j = -5,5,1 do
|
|
3 |
line = string.format("%2d mod %2d = ", i, j)
|
|
4 |
if j == 0 then
|
|
5 |
line = line .. "undefined"
|
|
6 |
else
|
|
7 |
line = line .. string.format("%d", i % j)
|
|
8 |
end
|
|
9 |
print(line)
|
|
10 |
end
|
|
11 |
end
|
|
0 |
program Hello;
|
|
1 |
|
|
2 |
var i: integer;
|
|
3 |
var j: integer;
|
|
4 |
|
|
5 |
begin
|
|
6 |
for i := -5 to 5 do
|
|
7 |
for j := -5 to 5 do
|
|
8 |
begin
|
|
9 |
if (i >= 0) then write(' ');
|
|
10 |
write(i, ' mod ');
|
|
11 |
if (j >= 0) then write(' ');
|
|
12 |
write(j, ' = ');
|
|
13 |
if (j = 0) then
|
|
14 |
writeln('undefined')
|
|
15 |
else
|
|
16 |
writeln(i mod j)
|
|
17 |
end
|
|
18 |
end.⏎
|