Last active
May 4, 2017 16:50
-
-
Save rschoultz/2087fd2cc7c1bb5b127469f7dd22c82c to your computer and use it in GitHub Desktop.
Another Fizzbuzz, with Java streams. Optimized for brevity.
This file contains 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
import java.util.stream.IntStream; | |
public class FizzBuzz { | |
public static void main(String[] args) { | |
IntStream.rangeClosed(1, 100).mapToObj(i -> { | |
String a; | |
a = i % 3 == 0 ? "Fizz" : ""; | |
a += i % 5 == 0 ? "Buzz" : ""; | |
return a.isEmpty() ? "" + i : a; | |
}).forEach(System.out::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment