Skip to content

Instantly share code, notes, and snippets.

@asiegman
Last active August 29, 2015 14:18
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 asiegman/2c7065a38cf4cc7f9397 to your computer and use it in GitHub Desktop.
Save asiegman/2c7065a38cf4cc7f9397 to your computer and use it in GitHub Desktop.
Fizz Buzz
#!/bin/bash
# Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz"
# instead of the number and for the multiples of five print "Buzz". For numbers which are multiples
# of both three and five print "FizzBuzz".
for i in {1..100} ; do
num=$i
[[ $(( $i % 3 )) == 0 ]] && echo -n "Fizz" && num=""
[[ $(( $i % 5 )) == 0 ]] && echo -n "Buzz" && num=""
echo $num
done
@asiegman
Copy link
Author

Having never interviewed as a programmer, I've never had the luxury of solving random programmer problems that hiring managers ask in interviews sometimes. I was reading this article here:

http://blog.codinghorror.com/why-cant-programmers-program/

And decided to give the Fizz Buzz problem a try. This took me about all of 2 minutes. I may have spent more time creating this gist and adding the comment than I did on the script. I'm a Linux SysAdmin and I guess these days, you could call me DevOps - not even a programmer by job title. Is it really that bad out there trying to hire programmers?

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