amp-blog-agent/fizzbuzz.sh

19 lines
489 B
Bash
Raw Permalink Normal View History

#!/etc/profiles/per-user/jmug/bin/zsh
# FizzBuzz implementation
# Prints numbers from 1 to 15
# For multiples of 3, print "Fizz" instead of the number
# For multiples of 5, print "Buzz" instead of the number
# For multiples of both 3 and 5, print "FizzBuzz"
for i in {1..15}; do
if (( i % 3 == 0 && i % 5 == 0 )); then
echo "FizzBuzz"
elif (( i % 3 == 0 )); then
echo "Fizz"
elif (( i % 5 == 0 )); then
echo "Buzz"
else
echo $i
fi
done