I thought I would submit my solution for the FizzBuzz test. I’ve used PowerShell and VBScript for the solution since the majority of my dev work is Windows scripting.
FizzBuzz for PowerShell:
for ($i = 1; $i -le 100; $i++)
{
if (($i % 3 -eq 0) -and ($i % 5 -eq 0))
{
Write-Host "FizzBuzz"
}
elseif ($i % 3 -eq 0)
{
Write-Host "Fizz"
}
elseif ($i % 5 -eq 0)
{
Write-Host "Buzz"
}
else { $i }
}
… and VBScript
Dim i
For i = 1 To 100
If ((i Mod 3 = 0) And (i Mod 5 = 0)) Then
WScript.Echo "FizzBuzz"
ElseIf (i Mod 3 = 0) Then
WScript.Echo "Fizz"
ElseIf (i Mod 5 = 0) Then
WScript.Echo "Buzz"
Else
WScript.Echo i
End If
Next