aboutsummaryrefslogtreecommitdiff
path: root/challenge-146/abigail/bash/ch-2.sh
blob: 5a5ee147f563c1239e47be9f4e72467e1a081f34 (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
#!/bin/sh

#
# See ../README.md
#

#
# Run as: bash ch-2.sh < input-file
#

set -f

IFS=/

while read a b
do   for ((i = 1; i <= 2; i ++))
     do  if   ((a < b))
         then ((b -= a))
         else ((a -= b))
         fi
         if   ((a == 0 || b == 0))
         then break
         fi
         printf "$a/$b "
     done
     echo
done