Last active
August 29, 2015 14:18
-
-
Save asiegman/2c7065a38cf4cc7f9397 to your computer and use it in GitHub Desktop.
Fizz Buzz
This file contains hidden or 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
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?