Skip to content

Instantly share code, notes, and snippets.

@jcefoli

jcefoli/fizzbuzz.ps1

Created Oct 24, 2019
Embed
What would you like to do?
[Powershell Interview Question] The FizzBuzz Problem: Write a program that prints the numbers 1 to 100. For multiples of 3, print "Fizz". For multiples of 5, print "Buzz". FOr multiples of both 3 and 5, print "FizzBuzz".
for ($x = 1; $x -le 100; $x++) {
$Output = ""
if ($x % 3 -eq 0) { $Output += "Fizz" }
if ($x % 5 -eq 0) { $Output += "Buzz" }
if ($Output -eq "") { $Output = $x }
Write-Output $Output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment