blob: 742922264289b2ee3d91d2f92cffce115b837cc4 (
plain)
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
|
#!/opt/local/bin/lua
--
-- See ../README.md
--
--
-- Run as: lua ch-2.lua < input-file
--
for line in io . lines () do
local _, _, a, b = line : find ("([0-9]+)/([0-9]+)")
a = tonumber (a)
b = tonumber (b)
for i = 1, 2 do
if a < b then
b = b - a
else
a = a - b
end
if a == 0 or b == 0 then
goto out_of_loop
end
io . write (a .. "/" .. b .. " ")
end
::out_of_loop::
io . write ("\n")
end
|