Last active
April 22, 2016 04:18
-
-
Save VallaDanger/3561e62d8b328d003ebaf3676476d765 to your computer and use it in GitHub Desktop.
FizzBuzz Java (recursive)
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 Main { | |
public static void main(String[] args) throws Exception { | |
System.out.println(getText(new StringBuilder("1,2,"), 3)); | |
} | |
private static StringBuilder build(StringBuilder sb, int i) { | |
if(i%3 == 0) { | |
sb.append("Fizz"); | |
} | |
if(i%5 == 0) { | |
sb.append("Buzz"); | |
} else if(i%3 != 0) { | |
sb.append(i); | |
} | |
return (i < 100) ? build(sb.append(','), ++i) : sb; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yet another way to solve the FizzBuzz problem