Created
June 2, 2019 01:41
-
-
Save mauriciodarocha/9ce3169b372e02639beb9464259e6ee8 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
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