Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.function.*;
- public class HelloWorld
- {
- public static void main(String []args)
- {
- System.out.println("Hello World");
- for (int i = 1; i <= 100; i++)
- System.out.println(fizzbuzz(i));
- }
- private static String fizzbuzz(int n)
- {
- Function<Function<String, String>, Function<String, String>> fizz = f ->
- (n % 3 == 0)
- ? s -> "Fizz" + f.apply("")
- : f;
- Function<Function<String, String>, Function<String, String>> buzz = f ->
- (n % 5 == 0)
- ? s -> "Buzz" + f.apply("")
- : f;
- return fizz.apply(buzz.apply(Function.identity())).apply(String.valueOf(n));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement