Skip to content

Instantly share code, notes, and snippets.

@chindraba-work
Created July 23, 2023 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chindraba-work/10e6c8bc9197003af432b60644c6692a to your computer and use it in GitHub Desktop.
Save chindraba-work/10e6c8bc9197003af432b60644c6692a to your computer and use it in GitHub Desktop.
#!/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
@chindraba-work
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment