Skip to content

Instantly share code, notes, and snippets.

@FedericoPonzi
Last active June 7, 2016 09:29
Show Gist options
  • Save FedericoPonzi/3f119ad63dc260d0c18a to your computer and use it in GitHub Desktop.
Save FedericoPonzi/3f119ad63dc260d0c18a to your computer and use it in GitHub Desktop.
My solution for the fizzbuzz test, in java
public class FizzBuzzTest
{
public static void main(String[] args)
{
for (int i = 1; i <= 100; i++)
{
String toPrint;
if(i%3 == 0 && i%5 == 0)
toPrint = "FizzBuzz";
else if(i%3 == 0)
toPrint = "Fizz";
else if(i%5 == 0)
toPrint = "buzz";
else
toPrint = "" + i;
System.out.println(toPrint);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment