@@ -0,0 +1,2545 @@
+import java.math.BigInteger;%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.stream.Collectors;%0Aimport java.util.stream.IntStream;%0Aimport org.openjdk.jmh.annotations.*;%0Aimport org.openjdk.jmh.infra.Blackhole;%0Aimport org.openjdk.jmh.runner.Runner;%0Aimport org.openjdk.jmh.runner.RunnerException; %0Aimport org.openjdk.jmh.runner.options.Options;%0Aimport org.openjdk.jmh.runner.options.OptionsBuilder;%0A%0A%0A@Warmup(iterations = 5)%0A@Measurement(iterations = 10)%0A@BenchmarkMode(Mode.AverageTime)%0A@OutputTimeUnit(TimeUnit.MILLISECONDS)%0A@State(Scope.Benchmark)%0A@Fork(2)%0Apublic class Factorial %7B%0A%0A    @Param(%7B%2210%22, %22100%22, %221000%22, %2210000%22, %2250000%22, %22100000%22%7D)%0A    private int n;%0A%0A    public static BigInteger streamedParallel(int n) %7B%0A        if (n %3C 2) %7B%0A            return BigInteger.valueOf(1);%0A        %7D%0A        return IntStream.rangeClosed(2, n).parallel().mapToObj(BigInteger::valueOf).reduce(BigInteger::multiply).get();%0A    %7D%0A    %0A    public static BigInteger revstreamedParallel(int n) %7B%0A        if (n %3C 2) %7B%0A            return BigInteger.valueOf(1);%0A        %7D%0A        return IntStream.iterate(n, i-%3Ei-1).limit(n-1).parallel().mapToObj(BigInteger::valueOf).reduce(BigInteger::multiply).get();%0A    %7D%0A   %0A    //Tree%0A    public static BigInteger ProdTree(int left, int right) %7B%0A        if (left %3E right) %7B%0A            return BigInteger.ONE;%0A        %7D%0A        if (left == right) %7B%0A            return BigInteger.valueOf(left);%0A        %7D%0A        if (right - left == 1) %7B%0A            return BigInteger.valueOf(left).multiply(BigInteger.valueOf(right));%0A        %7D%0A        int m = (left + right) / 2;%0A        return ProdTree(left, m).multiply(ProdTree(m + 1, right));%0A    %7D%0A%0A    public static BigInteger TreeFactorial(int n) %7B%0A        if (n %3C 0) %7B%0A            return BigInteger.ZERO;%0A        %7D%0A        if (n == 0) %7B%0A            return BigInteger.ONE;%0A        %7D%0A        if (n == 1 %7C%7C n == 2) %7B%0A            return BigInteger.valueOf(n);%0A        %7D%0A        return ProdTree(2, n);%0A    %7D%0A    %0A%0A    @Benchmark%0A    public void testStreamedParallel(Blackhole bh) %7B%0A        bh.consume(streamedParallel(n));%0A    %7D%0A    %0A    @Benchmark%0A    public void testTreeFactorial(Blackhole bh) %7B%0A        bh.consume(TreeFactorial(n));%0A    %7D%0A    %0A    %0A    %0A    public static void main(String%5B%5D args) throws RunnerException %7B%0A%0A         Options opt = new OptionsBuilder()%0A                .include(Factorial.class.getSimpleName())%0A                .forks(1)%0A                .build();%0A%0A        new Runner(opt).run();%0A    %7D%0A%7D%0A

Create Factorial.java