Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.hawaii.FizzBuzz;
- /*
- * Iterates from 1 to 100 and prints Fizz if the number
- * is a multiple of 3, Buzz if it's a multiple of 5, FizzBuzz
- * if it's a multiple of both, and the number otherwise
- *
- * Jordan Do
- */
- public class FizzBuzz {
- public static void main(String[] args) {
- for (int i = 1; i < 101; i++) {
- if (i % 3 == 0) System.out.print("Fizz");
- if (i % 5 == 0) System.out.print("Buzz");
- if (i % 3 != 0 && i % 5 != 0) System.out.print(i);
- System.out.println("");
- }
- }
- }
Add Comment
Please, Sign In to add comment