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

#
# See https://theweeklychallenge.org/blog/perl-weekly-challenge-001
#

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

while read max
do  for ((i = 1; i <= $max; i ++))
    do
        out=$i
        if (($i %  3 == 0))
        then out="fizz"
        fi
        if (($i %  5 == 0))
        then out="buzz"
        fi
        if (($i % 15 == 0))
        then out="fizzbuzz"
        fi
        echo $out
    done
done