Skip to content

Instantly share code, notes, and snippets.

@hasefumi23
Created December 4, 2016 10:09
Show Gist options
  • Select an option

  • Save hasefumi23/c5174c311d2087512e2a3605b39ac1e3 to your computer and use it in GitHub Desktop.

Select an option

Save hasefumi23/c5174c311d2087512e2a3605b39ac1e3 to your computer and use it in GitHub Desktop.
スタイリッシュなFizzBuzz(Java8) ref: http://qiita.com/F_H_23/items/e18f8e1686bedf31d93e
public class FizzBuzz {
public static void main(String[] args) {
IntStream.rangeClosed(1, 100).mapToObj(n ->
(n % 15 == 0) ? "FizzBuzz" :
(n % 3 == 0) ? "Fizz" :
(n % 5 == 0) ? "Buzz" :
String.valueOf(n))
.collect(Collectors.toList()).forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment