Created
July 23, 2023 14:31
-
-
Save chindraba-work/10e6c8bc9197003af432b60644c6692a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# SPDX-License-Identifier: MIT | |
# Copyright 2023 Chindraba (Ronald Lamoreaux) <projects@chindraba.work> | |
for n in {1..100} | |
do | |
a='' | |
((0==n%3)) && a='Fizz' | |
((0==n%5)) && a="${a}Buzz" | |
echo "${a:-$n}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As a one-liner, it becomes:
for n in {1..100};do a='';((0==n%3))&&a='Fizz';((0==n%5))&&a="${a}Buzz";echo "${a:-$n}";done