Skip to content

Instantly share code, notes, and snippets.

@idavis
Created November 21, 2012 23:15
Show Gist options
  • Save idavis/4128478 to your computer and use it in GitHub Desktop.
Save idavis/4128478 to your computer and use it in GitHub Desktop.
FizzBuzz with PowerShell
filter Fizz-Buzz {
process {
$output = switch($_) {
{$_ % 3 -eq 0} {"Fizz"}
{$_ % 5 -eq 0} {"Buzz"}
default {$_}
}
$output -join ""
}
}
filter Fizz-Buzz2 {
process {
($_ = switch($_) { {$_ % 3 -eq 0} {"Fizz"} {$_ % 5 -eq 0} {"Buzz"} default {$_} }) -join ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment