//I hardly consider myself above average⌠wow⌠very sad!
//off the top of my head i figured i try it out⌠works just fineâŚ
public class fizzBuzz
{ public static void main(String[] args)
{
String[] x= new String[100];
for (int i=0; i<100; i++)
if (i%3==0 && i%5==0)x[i]=âFizzBuzzâ;
else if (i%3==0)x[i]=âFizzâ;
else if (i%5==0)x[i]=âBuzzâ;
else x[i]=Integer.toString(i);
for (int i=0; i<100; i++) System.out.print(x[i] + ", ");
}
}
Haha, I just whipped this up in VBScript.
Iâm @ Durham College in Ontario, Canada and am taking Computer Systems.
My program is focused on networking and server administration, the other half of us are in the Computer Programmer side of things.
However, we take a few programming here and there, mostly intro to VB and C++, as well as batch/shell scripting and PHP/VBScript.
It saddens me that I, a beginner programmer (in my opinion), can easily whip this code snippet up in about 5min and be more qualified than 99% of âprogrammersâ.
Anyways, hereâs my snippet in VBScript, Iâm sure it would work in VB.NET as well.
â fizzbuzz.vbs
Dim i
Const FIZZ=3, BUZZ=5
i = 1
For i = 1 To 100
If i Mod FIZZ = 0 Then
Wscript.Echo "Fizz"
ElseIf i Mod BUZZ = 0 Then
Wscript.Echo "Buzz"
ElseIf i Mod (FIZZ+BUZZ) = 0 Then
Wscript.Echo "FizzBuzz"
Else
Wscript.Echo i
End If
Next
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0)
{
Console.Write("Fizz");
}
if (i % 5 == 0)
{
Console.Write("Buzz");
}
if (i % 5 > 0 && i % 3 > 0)
{
Console.Write(i);
}
Console.WriteLine("");
}
Console.ReadKey();
}
}
Only a hobbyist, but here is my Google Go solution:
package main
import fmt âfmt"
func main() {
for i := 1; i <= 100; i++ {
switch {
case i % 15 == 0 :
fmt.Printf(âFizzBuzzâ)
case i % 3 == 0 :
fmt.Printf(âFizzâ)
case i % 5 == 0 :
fmt.Printf(âBuzzâ)
default:
fmt.Printf(â%d", i)
}
fmt.Printf("\n")
}
}
begin
for i:=1 to 100 do begin
if (i mod 15 = 0) then
WriteLn(âFizzBuzzâ)
else if (i mod 3 = 0) then
WriteLn(âFizzâ)
else if (i mod 5 = 0) then
WriteLn(âBuzzâ)
else WriteLn(IntToStr(i));
end;
end;
Just throwing in my 2 cents for python (even though weâre getting âyelledâ at for posting answers Iâm new as hell to python (few months) and I got the problem in ~5 minutes of tinkering.
for i in range (1,101):
if (i % 3) == 0 and (i % 5) == 0:
print 'fizzbang'
elif i % 3 == 0:
print 'fizz'
elif i % 5 == 0:
print 'bang'
else:
print i
/* cc -std=c99 main.c -o fizzbuzz */
#include <stdio.h>
int
main(int argc, char *argv[])
{
for (int i = 1; i < 101; i++) {
if (i % 3 == 0)
printf("Fizz");
if (i % 5 == 0)
printf("Buzz");
if (i % 3 && i % 5)
printf("%d",i);
printf("\n");
}
}