Created
December 4, 2016 11:39
-
-
Save chrisbrownie/1111c7a922008b7f857f6cb7a19aaa59 to your computer and use it in GitHub Desktop.
My PowerShell solution to the fizzbuzz question https://blog.codinghorror.com/why-cant-programmers-program/
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
# https://blog.codinghorror.com/why-cant-programmers-program/ | |
function FizzBuzz { | |
0..100 | % { | |
if ( ( $_ % 3 -eq 0 ) -and ( $_ % 5 -eq 0 ) ) { | |
"$_ fizzbuzz" | |
} elseif ( $_ % 3 -eq 0) { | |
"$_ fizz" | |
} elseif ( $_ % 5 -eq 0) { | |
"$_ buzz" | |
} else { | |
$_ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment