Created
October 24, 2019 20:29
-
-
Save jcefoli/f8c81994f2575eed5e640752742d669e to your computer and use it in GitHub Desktop.
[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".
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
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