Created
March 5, 2010 00:07
-
-
Save brianmacdonald/322291 to your computer and use it in GitHub Desktop.
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
/* | |
* Title: Fizzbuzz (Java Coding Sample) | |
* Author: Brian Macdonald | |
* Description: | |
* Program that prints the numbers from 1 to 100. But for multiples of | |
* three print "Fizz" instead of the number and for the multiples of five | |
* print "Buzz". For numbers which are multiples of both three and five | |
* print "FizzBuzz". | |
*/ | |
class FizzBuzz{ | |
public static void main(String args[]){ | |
for (int x = 1; x <= 100; x++){ | |
if ((x % 3 == 0) && (x % 5 == 0)){ | |
System.out.println("FizzBuzz"); | |
} else if(x % 3 == 0){ | |
System.out.println("Fizz"); | |
} else if(x % 5 == 0){ | |
System.out.println("Buzz"); | |
} else { | |
System.out.println(x); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment