Skip to content

Instantly share code, notes, and snippets.

@DavyLin
Created May 5, 2014 06:47
Show Gist options
  • Select an option

  • Save DavyLin/4528e07165717178070a to your computer and use it in GitHub Desktop.

Select an option

Save DavyLin/4528e07165717178070a to your computer and use it in GitHub Desktop.

Revisions

  1. DavyLin renamed this gist May 5, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. DavyLin created this gist May 5, 2014.
    25 changes: 25 additions & 0 deletions gistfile1.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    public class FizzTest {
    public static void main(String[] args) {
    String string = "";
    String[] nums = new Scanner(System.in).next().split(",");
    for (int i = 1; i <= 100; i++) {
    if (String.valueOf(i).indexOf(nums[0]) != -1) {
    string += "Fizz";
    } else {
    if (i % Integer.parseInt(nums[0]) == 0) {
    string += "Fizz";
    }
    if (i % Integer.parseInt(nums[1]) == 0) {
    string += "Buzz";
    }
    if (i % Integer.parseInt(nums[2]) == 0) {
    string += "Whizz";
    } else if (i % Integer.parseInt(nums[0]) != 0 && i % Integer.parseInt(nums[1]) != 0 && i % Integer.parseInt(nums[2]) != 0) {
    string += i;
    }
    }
    string += "\n";
    }
    System.out.println(string);
    }
    }