package test;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.stream.IntStream;
public class FunctionalFactorial {
package test;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.stream.IntStream;
public class FunctionalFactorial {
@FunctionalInterface
public interface FactorialFunc<T> {
T factorial (T t);
}
@Test
public void testFactorial() {
int value = 5;
FactorialFunc<Integer> f = (x) -> IntStream.rangeClosed(1, 5).reduce((i,j) -> i * j).getAsInt();
Assert.assertEquals(120, f.factorial(value));
}
}
}