Java examples for Lambda Stream:IntStream
combination from factorial via IntStream
//package com.java2s; import java.util.stream.IntStream; public class Main { public static int combination(final int n, final int k) { return factorial(n) / (factorial(k) * factorial(n - k)); }/*from w w w . j av a2 s. c om*/ public static int factorial(final int n) { return IntStream.rangeClosed(1, n).reduce((x, y) -> x * y).getAsInt(); } }