Skip to content

Instantly share code, notes, and snippets.

@mauriciodarocha
Created June 2, 2019 01:41
Show Gist options
  • Save mauriciodarocha/9ce3169b372e02639beb9464259e6ee8 to your computer and use it in GitHub Desktop.
Save mauriciodarocha/9ce3169b372e02639beb9464259e6ee8 to your computer and use it in GitHub Desktop.
public class MyClass {
public static void main(String args[]) {
String results = FizzBuzz(1,20);
System.out.println(results);
}
public static String FizzBuzz(int k, int l){
String n = "";
for(int i=k;i<=l;i++){
if(i%3==0)
n += "Fizz";
if(i%5==0)
n += "Buzz";
if(i%3!=0 && i%5!=0)
n += Integer.toString(i);
if(i<l)
n += ",";
}
return n;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment